Общий форумI've got a wrong answer on test 15. By the way... in order to satisfy condition #4 we need to test each "good" point with each "good" point? won't it be too much iterations for n=10000? P.S. "good" point is the point that satisfy the current arc? I tried my solution, I think it should use at most 2MB of memory and got MLE on first test? Is it c# related problem or my solution is that bad? up: i checked the memory usage for 30000 60 10, it's about 300000*4 bytes #include<iostream> #include<string> using namespace std; int n,sum[999],l=0; char a[101],b[101]; int main(){ cin>>n; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; for(int i=0;i<n;i++){ if(a[i]=='a') a[i]='1'; if(a[i]=='b') a[i]='2'; if(a[i]=='c') a[i]='3'; if(a[i]=='d') a[i]='4'; if(a[i]=='e') a[i]='5'; if(a[i]=='f') a[i]='6'; if(a[i]=='g') a[i]='7'; if(a[i]=='h') a[i]='8'; } for(int i=0;i<n;i++){ if(a[i]-48+2<=8&&a[i]-48+2>0&&b[i]-48+1<=8&&b[i]-48+1>0) sum[i]=sum[i]+1; if(a[i]-48+1<=8&&a[i]-48+1>0&&b[i]-48+2<=8&&b[i]-48+2>0) sum[i]=sum[i]+1; if(a[i]-48-1<=8&&a[i]-48-1>0&&b[i]-48+2<=8&&b[i]-48+2>0) sum[i]=sum[i]+1; if(a[i]-48-2<=8&&a[i]-48-2>0&&b[i]-48+1<=8&&b[i]-48+1>0) sum[i]=sum[i]+1; if(a[i]-48-2<=8&&a[i]-48-2>0&&b[i]-48-1<=8&&b[i]-48-1>0) sum[i]=sum[i]+1; if(a[i]-48-1<=8&&a[i]-48-1>0&&b[i]-48-2<=8&&b[i]-48-2>0) sum[i]=sum[i]+1; if(a[i]-48+1<=8&&a[i]-48+1>0&&b[i]-48-2<=8&&b[i]-48-2>0) sum[i]=sum[i]+1; if(a[i]-48+2<=8&&a[i]-48+2>0&&b[i]-48-1<=8&&b[i]-48-1>0) sum[i]=sum[i]+1; } for(int i=0;i<n;i++) cout<<sum[i]<<endl; } Подсказка Используйте + var n,i,j,k:integer;s:real;a:array[1..20,1..20] of real;zer:boolean; label 1; begin s:=1; readln(n); for i:=1 to n do for j:=1 to n do read(a[i,j]); for k:=1 to n-1 do if a[k,k]=0 then begin zer:=true;goto 1; end else for i:=k+1 to n do for j:=k+1 to n do a[i,j]:=a[i,j]-a[i,k]*a[k,j]/a[k,k]; for k:=1 to n do s:=s*a[k,k]; writeln(s:0:0); 1:if zer then writeln('0'); for i:=1 to n do begin for j:=1 to n do write(a[i,j],' '); writeln; end; end. var a:array[1..100,1..100] of integer;k,n,m,max,x,y,i,j:integer; begin readln(n,m); readln(x,y); for i:=1 to n do for j:=1 to n do a[i,j]:=abs(i-x)+abs(j-y); for k:=1 to m-1 do begin readln(x,y); for i:=1 to n do for j:=1 to n do if a[i,j]>abs(i-x)+abs(j-y) then a[i,j]:=abs(i-x)+abs(j-y); end; for i:=1 to n do for j:=1 to n do if a[i,j]>max then max:=a[i,j]; writeln(max); end. var ab,bc,ac,ad,bd,cd:real; a1,a2,a3,a4,b1,b2,b3,b4:real; s,s1,s2,s3:real; function stor(x,y,z,t:real):real; begin stor:=sqrt((sqr(x-y))+(sqr(z-t))); end; function square(n,k,v:real):real; var m:real; begin m:=(n+k+v)/2; square:=trunc(sqrt(m*(m-n)*(m-v)*(m-k))*10); end; begin {repeat} writeln ('Введите координату вершины A'); readln (a1,b1); writeln ('Введите координату вершины B'); readln (a2,b2); writeln ('Введите координату вершины C'); readln (a3,b3); writeln ('Введите координаты точки D'); readln(a4,b4); AB:=stor(a1,a2,b1,b2); BC:=stor(a2,a3,b2,b3); AC:=stor(a1,a3,b1,b3); ad:=stor(a1,a4,b1,b4); bd:=stor(a2,a4,b2,b4); cd:=stor(a3,a4,b3,b4); {if(AB>=BC+AC)or(AC>=AB+BC)or(BC>=AB+AC) then writeln('Это не треугольник, введите данные заново'); until (AB<BC+AC)and(AC<AB+BC)and(BC<AB+AC);} s:=square(ab,bc,ac); s1:=square(ab,bd,ad); s2:=square(bd,cd,bc); s3:=square(cd,ad,ac); {writeln(s,' ',s1,' ',s2,' ',s3);} if abs(s-s1-s2-s3)<5 then writeln ('точка D является внутренней точкой треугольника ABC') else writeln ('точка D не является внутренней точкой треугольника ABC'); {writeln(abs(s-s1-s2-s3));} end. I have strange problem, my code is compiled well on my home PC (MS VC++ 2010 also), but the same code getting compilation error on Timus. Let me present here a fragment of my code (All problem-related part was expunged, only variable declaration-initialization and input remained). This is also a compilable code on my PC. Can you consider it please. Thanks in advance. #pragma comment(linker, "/STACK:5000000") #include <iostream> using namespace std; int main() { char tmp, or[250001], samp[750002]; int N, z[750002]; memset(&z[0], 0, 750002*4); scanf("%i", &N); scanf("%c", &tmp); cin.getline(or, 250001); cin.getline(samp, 750002); return 0; } Code above gives CE on Timus: 8002b36b-0800-4fc8-aa2b-53e6cb233ddd 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(7) : error C2059: syntax error : '||' 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(12) : error C2143: syntax error : missing ')' before '||' 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(12) : error C2661: 'std::basic_istream<_Elem,_Traits>::getline' : no overloaded function takes 0 arguments with [ _Elem=char, _Traits=std::char_traits<char> ] 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(12) : error C2059: syntax error : ',' 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(12) : error C2059: syntax error : ')' 8002b36b-0800-4fc8-aa2b-53e6cb233ddd(13) : error C2065: 'samp' : undeclared identifier try rename array "or", I think it can resolve problem Thanks, the idea of renaming really worked! Why? code pascal program z1; var s, s1:string; n, x:longint; begin readln(n); readln(s); readln(s1); if s=s1 then write(0) else begin s:=s+s; case pos(s1, s) of 1..250000:writeln(n-pos(s1, s)+1); else write(-1); end; end; readln; end. Your algorithm is wrong, read more about KMP algorithm or string hashing P.S. Test for you: aaa...aaa aaa...aab Input: abc Expected output: a My program was failing test 2 because I was not initialing correctly and so returned b for this case. Just in case any one else has this problem. Thanks a lot I never thought of initializing the first character. Got AC once fixed :) Thank you.You are such a helpful person. What is in test 33 ? The same code with Scanner is accepted but with StreamTokenizer and BufferedReader is giving WA33. Very unexpected result!! O_O Edited by author 16.12.2012 10:56 There is one typo in both codes: Beautiful, not Beutiful. readln(a); b:=0; if a>=0 then for i:=1 to a do begin b:=b+i; end else for i:=1 downto a do begin b:=b+i; end; writeln(b); Edited by author 13.12.2012 00:05 Why not check that the number is positive or negative. You can simply like this: for i := 1 to a do begin b : = (b + i; end. Change and try it. Should earn. Good luck :) ! I may be mistaken, but the program is not true, namely, in the test, when the input number 0 (a = 0), the output of your number will be 0 instead of 1 .. And this is just a linear program ... that is the sum of an arithmetic progression .. Sorry for my English :) Var a,b:array [0..3] of string; c,d:string[4]; N,I,J:LongInt; P:Boolean; Begin Readln(C); Readln(D); P:=FALSE; A[0]:=C[1];A[1]:=C[2];A[2]:=C[3];A[3]:=C[4]; B[0]:=D[1];B[1]:=D[2];B[2]:=D[3];B[3]:=D[4]; If A[0]=B[0] Then If ((A[1]=B[1]) and (A[2]=B[2]) and (A[3]=B[3])) or ((A[1]=B[3]) and (A[2]=B[1]) and (A[3]=B[2])) or ((A[1]=B[2]) and (A[2]=B[3]) and (A[3]=B[1])) Then P:=True; If A[0]=B[2] Then If ((A[1]=B[1]) and (A[2]=B[3]) and (A[3]=B[0])) or ((A[1]=B[3]) and (A[2]=B[0]) and (A[3]=B[1])) or ((A[1]=B[0]) and (A[2]=B[1]) and (A[3]=B[3])) Then P:=True; If A[0]=B[3] Then If ((A[1]=B[1]) and (A[2]=B[0]) and (A[3]=B[2])) or ((A[1]=B[2]) and (A[2]=B[1]) and (A[3]=B[0])) or ((A[1]=B[0]) and (A[2]=B[2]) and (A[3]=B[1])) Then P:=True; If P=True Then Writeln('equal') Else Writeln('different'); End. Say me why this program not work? Edited by author 01.12.2007 21:32 Edited by author 01.12.2007 21:33 #include <iostream> #include <vector> #include <math.h> #include <iomanip> #define ACCURACITY 4 using namespace std; int main() { vector<double> m; while (1) { double tmp; cin>>tmp; if (cin.eof()){break;} m.push_back(tmp); } for (int i=m.size()-1; i > -1; --i) { cout<<endl<<setprecision(ACCURACITY)<<fixed<<sqrt(m[i]); } } the results are the same with results of the task Edited by author 14.12.2012 22:23 My solution of 1005 problem was accepted. Here it is: #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n,t; vector<int> w; cin >> n; for(int i = 0; i < n; ++i) { cin >> t; w.push_back(t); } sort(w.begin(), w.end()); vector<int>::reverse_iterator it = w.rbegin(); vector<int>::reverse_iterator end = w.rend(); int s = 0; for(; it != end; ++it) s += *it; it = w.rbegin(); s = s/2 + (s%2); int l = 0, r = 0; for(; it != end; ++it) if(l + *it <= s) l += *it; else r += *it; cout << abs(l-r) << endl; return 0; } But there is a test, where this solution gives a wrong answer: 6 101 51 51 3 2 2 Yeah, right answer is 0, but your 2.. I hope that admins will add some new tests. Edited by author 11.08.2012 20:16 what answer for this test: 0 0 1 0 1 1 2 1 0 or -1 ? 0, cause a line doesn't have the area. Run the program on this test: n = 50000 0 1 1 1 2 1 ... i i+1 1 ... 50000-2 50000-1 1 m = 1 0 1 Edited by author 14.12.2012 05:58 Edited by author 14.12.2012 05:58 f2ba8f04-8e51-4a98-89b6-0170582bbb1b(21) : error C3861: 'getline': identifier not found but in the sample (in the FAQ) getline method is used I have similar problem, my code is compiled well on my home PC (MS VC++ 2010), but the same code getting compilation error on Timus. Let me present here a fragment of my code (All problem-related part was expunged, only variable declaration-initialization and input remained). This is also a compilable code on my PC. Can you consider it please. Thanks in advance. #pragma comment(linker, "/STACK:5000000") #include <iostream> using namespace std; int main() { char tmp, *or, *samp; or = new char[250001]; samp = new char[750002]; int N, z[750002]; memset(&z[0], 0, 750002*4); scanf("%i", &N); scanf("%c", &tmp); cin.getline(or, 250001); cin.getline(samp, 750002); return 0; } P.S. Adding "#include <string>" didn't helped. Edited by author 13.12.2012 21:44 somebody help me!!!!! i get crash(integer division by zero) at test#1!!!!!!! wtf is this test case?? "integer division by zero" i don't see anywhere i divided a number by zero!! In some discussions people give tests with the precise test number, but I couldn't find tests of any exercices in main site and in problem exposition, so my question is: Where can I find timus' tests? Are there in some place or people got them in other ways? Thank in advance. People who give tests don't surely know their numbers. The scheme is as follows: We write our solution on some problem, submit it and for example get verdict "Wrong Answer 5". Then we try to test our solution on tests, which we generate "at home". If we find such test on which our solution gives wrong answer, we fix mistake in program and submit it again. If new verdict is "Accepted" or for example "Wrong Answer 8", we will understand that Test 5 could be the same or similar like our. Thanks a lot, I've finally understood how it works. Check that all of arrays in your source less that 64 KB! (MS VC compiler limitation) help me! use only ''while not eof'' |
|