Common BoardShow all threads Hide all threads Show all messages Hide all messages  9th test  Shohin  2011. Long Statement  21 Mar 2018 07:12  3  test 2 1 1 1 1 1 1 ans: Yes  Time limit exceeded on tes 8 (java), i dont know which way is excellent  Aydar  1654. Cipher Message  21 Mar 2018 06:11  4  import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.Stack; public class problem1654 { public static void main(String[] args) throws IOException { BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); String str=inp.readLine(); Stack<Character> st=new Stack<Character>(); st.push(str.charAt(0)); String s=""; for(int i=1;i<str.length();i++){ if(!st.empty()&&st.peek()==str.charAt(i)) st.pop(); else{ st.push(str.charAt(i));
} }
while(!st.empty()){ s=s+st.pop(); } int n=s.length(); for(int i=0;i<n;i++){ System.out.print(s.charAt(ni1));
} }} When i used stack(from STL) in C++, i'd got TL8. But after i realzed stack by using array, i got AC your reply help me very much!3Q Don't use : while(!st.empty()){ s=s+st.pop(); }  Use this phrase at the end of your Code: Iterator<Character> b = st.iterator(); while(b.hasNext()){ System.out.print(b.next()); }  Incorrect unswer. Unknown  Ayrat  1002. Phone Numbers  20 Mar 2018 19:07  1  Here is my code and here is my output. Everything should work! What's wrong ? What requirements have I not fulfilled? http://lpaste.net/13924843521971322887325189087 5 it your reality real our reality our 4294967296 5 it your reality real our No solution. 1 The code is written in pure C. The compiler is gcc  hints  ASK  1234. Bricks  20 Mar 2018 16:02  1  hints ASK 20 Mar 2018 16:02 for allinteger comparison you have to use int64_t do not derive the inequality by hand, use Maxima: rot(c,s) := matrix([c,s],[s,c]); /* D: sqrt(a^2+b^2); */ ma: rot(e/D, sqrt(D^2e^2)/D); mb: rot(b/D, a/D); dd: (ma.mb.[a,b])[1][1],ratsimp; load(ineq)$ assume(D>0)$ assume(a>0)$ assume(b>0)$ assume(d>0)$ assume(e>0)$ ne: d >= dd; ne: (ne * D^2)2*a*b*e,ratsimp;  what went wrong here? I compiled it in dr.Java and it was okay  Riyad Ahsan Auntor  1068. Sum  20 Mar 2018 04:51  4  import java.util.Scanner; public class Sum{ public static void main(String args[]){ Scanner sc= new Scanner(System.in); int N, sum=0; System.out.print("Enter the value of N:"); N= sc.nextInt(); if(N<10000){ if(N<0){ for(int x=N; x<=1; x++){ sum+=x; } } else{ for(int x=1; x<=N; x++){ sum+=x; } } } System.out.println(sum); } } System.out.print("Enter the value of N:"); comment this out, automatic checker doesn't know that this text isn't the part of your answer yup did that too and it still says wrong answer Okaaaaay... if(N<10000){ i assume you wanted to check here if input data is correct, but there's no need to do that, input data is correct by default. Not to mention that you do it wrong, you check if N is between (infinity; 9999], while N should be between [10000; 10000]. Also i think you don't handle the N=0 case correctly, but hopefully you'll figure out why without more hints.  No subject  Ivan  1068. Sum  19 Mar 2018 23:50  1  Edited by author 20.03.2018 00:35  An efficient solution  2ch  1223. Chernobyl’ Eagle on a Roof  19 Mar 2018 20:39  1  Define d[i][j] to be the maximum number of floors that can be checked with i eggs after j steps. To answer the query one should do the binary search to find number of steps X such that d[input_eggs][X] >= input_floors with X being smallest possible. d[i][i] = i, d[2][5] = 15 ,d[2][6] = 21 ( 1 > 6 > 11 > 15 > 18 > 20 > 21 ) d[i][j] = d[i  1][j] + d[i  1][j  1] + 1; Explanation of the formula: Suppose we know d[i][j  1] and d[i  1][j  1] Throw an egg from (d[i  1][j  1] + 1) floor. Did it break? If yes, we can definitely check all floors from the first to d[i  1][j  1]th with remaining i  1 eggs within remaining j  1 steps. If it didn't then you just check how many floors you can check at most with i eggs within j  1 steps starting from ((d[i  1][j  1] + 1) + 1) th floor d[i][j] can be calculated in N^2 Query is answered in log(N) time My Java 1.8 solution runs in 0.062s. Edited by author 19.03.2018 20:45  Comp error  nexerd  1119. Metro  19 Mar 2018 16:47  2  while (n>0) { b=a; b=b/pow(10,n1)  rezult/pow(10,n1); for (int i=1;i<10;i++) if ((bi>=0)&(bi1<0)) rezult += (i)*pow(10,n1); n; } /* if delete : b=b/pow(10,n1)  rezult/pow(10,n1); for (int i=1;i<10;i++) if ((bi>=0)&(bi1<0)) rezult += (i)*pow(10,n1);  work! */ 1. Which programming language do you use? 2. Did you name the variable for result "rezult" (if there is need to predeclare variables in yout PL)?  WA 5  Ildar Valiev  1709. PenguinAvia  19 Mar 2018 04:11  16  WA 5 Ildar Valiev 4 Apr 2009 15:24 Can anybody give some test to judge my prog? I have WA on 5 test and cann't find my mistake. Ohhh! So stupid mistake)) Ohhh! So stupid mistake)) what? I use dfs and add edge between two pieces. I should use int64....... Edited by author 05.04.2009 07:22 When do you add edge between two pieces? This is a "boundary values" test. Consider a case when you have initially a full graph of ones  you have ~100^2 = 10^4 flights, and d=10^6. How much have you pay then to optimize the flights scheme? FT~~~~ I didn't know that long long is not supported. OH!!!!FT.. Realy, It's the problem ~ I didn't know that long long is not supported ,either ~ maybe the judge should update its compiler? Oh,I See.So we can only use "%I64d" to input/output?for I got WA while using "%lld" but AC with "%I64d" I know abbreviations AC, WA, TLE, DFS, BFS, DP... But what does FT stand for??? Re: WA 5 Валентин Дядька 19 Mar 2018 04:11  test for wrong #14  Bahodir  TUIT   1404. Easy to Hack!  18 Mar 2018 02:49  2  test for wrong #14: input a h output v c Hm. Let's try to encrypt this output: v > 21 + 5 = 26 mod 26 = 0 > a; c > 2 + 26 = 28 mod 26 = 2 > c; So, the correct input must be "ac". P.S. "ah" decodes to "vh". Edited by author 18.03.2018 02:50  WA 1!?  kaifonaft  1305. Convex Hull  18 Mar 2018 02:35  3  WA 1!? kaifonaft 26 Oct 2010 03:18 first test is not sample. Edited by author 26.10.2010 19:06 The test has only one point. and it is far away from 0  My algorithm is too slow.It takes more than 0.6sec.So,somebody got AC less than 0.3sec,would you please send your progeam to me?(yym2008@hotmail.com)  Yu YuanMing  1168. Radio Stations  18 Mar 2018 00:55  6  Mine is 0.156s. I use searching and some calculation. I think maybe you got an slow algrithm with only searching. I got AC in 0.14 sec and didn't use any kind of special things. Just stupid counting Hmin and Hmax for each point of the matrix now it is 0.031 s sorting stations by radius does not change anything  Java как короче?  Anton  1000. A+B Problem  17 Mar 2018 13:28  2  import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(in.nextInt()+in.nextInt()); } } Много весит и долго делает, подскажите, как облегчить и ускорить? you have to declare variables and place the input there.  checker  ASK  1659. Regular Triangles  17 Mar 2018 02:18  1  #!python3 s = """0 30 25.9807621135 15 25.9807621135 15 3.711537444785714 10.714285714285715 11.134612334357143 2.142857142857144 7.423074889571431 8.571428571428571 18.557687223928568 23.57142857142857 29.69229955828571 4.285714285714285 11.134612334357145 27.857142857142854""" import matplotlib.pyplot as plt from math import cos, sin, pi fig = plt.figure() ax = fig.add_subplot(111,aspect='equal') r=[[float(a) for a in p.split()] for p in s.split("\n")] def d(a,b): return (r[a][0]r[b][0])**2 + (r[a][1]r[b][1])**2 def z(a,b): return abs(ab) < 1e6 a = 0 for i in range(len(r)): for j in range(i+1,len(r)): for k in range(j+1,len(r)): if z(d(i,j),d(i,k)) and z(d(i,j),d(j,k)) and z(d(j,k),d(i,k)): a += 1 x = [r[t][0] + 0.5*cos(2*pi*a/9) for t in (i,j,k,i)] y = [r[t][1] + 0.5*sin(2*pi*a/9) for t in (i,j,k,i)] plt.plot(x, y, '') for p in r: plt.plot(p[0],p[1],'bo') plt.grid() plt.show() print(a)  can anyone write shorter solotion than mine ?  Saber  1082. Gaby Ivanushka  17 Mar 2018 00:47  14  here is mine : var n,i : longint; begin readln (n); for i := 1 to n do write (i,' '); end. U can use integer instead of longint and also write for loop, in just one line!!! anyhow... solotion has no meaning! you should say: solution... Your Friend Aidin_n7 program tm_1082; var N: 0..1000; begin Readln(N); while boolean(n) do begin write(N,' '); Dec(N) end; end. var n,i :integer; begin readln(n); for i := 1 to n do write(i,' '); end. #include <stdio.h> void main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) printf("%d ",i); } NOT shorter BUT better i can give you a hint... ok we start with 1 if you input 1>ok if you input 1>ok if you input 3>ok if you input 7(3*2+1)>ok if you input 19(7*2+3*2)>ok if you input 52(19*2+7*2)>ok ............................... have you got it.... if not stat with 1; read n a=1; b=3; n; write b a=b; b=a+b*2; for 1>n { write b*2+a*2 } :) not shorter but better:D #include<cstdio> int main(){int n;scanf("%d",&n);for(;n;n)printf("%d ",n);} Edited by author 16.09.2010 04:37 #include<stdio.h> main(){int n;scanf("%d",&n);while(n*printf("%d ",n));} Edited by author 23.10.2010 21:23 Edited by author 23.10.2010 22:24 #include<stdio.h> main(){int n;scanf("%d",&n);while(n*printf("%d ",n));} Concise, but, strictly speaking, is not guaranteed to work properly  as it is with all expressions of kind a[i] = i++. E.g., clang gives error  "unsequenced modification and access to 'n'". The problem here is that in C/C++ all sideeffects of arguments to functions are computed *before* function call. To fix this, we need to introduce a sequence point (https://en.wikipedia.org/wiki/Sequence_point)  e.g., comma: #include<stdio.h> main(){int n;scanf("%d",&n);while(n*printf("%d ",n),n);} Edited by author 12.02.2016 12:31print(*list(int(x)+1 for x in range(int(input())))) can anyone shorter? Edited by author 28.02.2016 00:45 41 bytes (Python 2.7) print ' '.join(map(str,range(int(input())))) 27 bytes (Python 3.6) print(*range(int(input()))) Edited by author 17.03.2018 00:52  WA 2  Desargues  1204. Idempotents  16 Mar 2018 14:36  2  WA 2 Desargues 7 Jan 2014 04:50 I have wrong answer on test 2, but all tests that I checked have right answer. Please, give me some tests to check my code. Edited by author 16.03.2018 14:36  No subject  Yaroslaff  1430. Crime and Punishment  16 Mar 2018 13:04  1   WA11  Didi (OSU11)  1423. String Tale  16 Mar 2018 01:25  1  WA11 Didi (OSU11) 16 Mar 2018 01:25 Get me test, please! I use kmp.  Знаки  + *  Alisher Kalykov  2066. Simple Expression  15 Mar 2018 19:29  2  Знаки нужно использовать все или нет? Знак "+" можно не использовать  Instruction how to solve.  Mahilewets  2099. Space Invader  15 Mar 2018 19:04  3  Check (AB,CD)==0 (orthogonality). Check (AB, CD, DA) ==0 (planarity). Check AD>AC>AB, AC>BC, BD>BC (order). Check whether the projections to XY, YZ, XZ craddle each other continuations. It is sufficient to check only the projections to XY plane to get Accepted verdict. Sounds too complex. If we replace C, D with their orthogonal projection on AB, then all steps except first collapse to only one step (check D = C*a, a > 1). Still too complex, though. Over 20 lines in Python. There should be more simple solution... Edited by author 26.12.2017 04:30 No lengths or projections XY, etc. Using scalar product (sp) and triple product (tp) it is at most five conditions: sp(ab,cd) == 0 and tp(ab,bc,cd) == 0 and # ⟂ and planar sp(ab,bc) >= 0 and # C after B sp(cd,bc) >= 0 and # BC goes in direction of CD sp(cd,bd) >= sp(cd,bc) # D after C 

