Common Board12 234 1344 80.7365278858 10 11 12 0 1 999 1000 487.6458506118 Program NoName; var n,r,i:integer; x: array [1..100] of real; y: array [1..100] of real; s,sg:real; input,output:text; begin s:=0; assign(input, 'input.txt'); reset(input); assign(output, 'output.txt'); rewrite(output); readln(n,r); if n=1 then writeln(1.00)else begin For i:=1 to n do readln(x[i],y[i]); sg:=2*pi*r; For i:=1 to n-1 do s:=s+sqrt(sqr(x[i]-x[i+1])+sqr(y[i]-y[i+1])); s:=s+sqrt(sqr(x[n]-x[1])+sqr(y[n]-y[1])); s:=s+sg; end; writeln(s:1:2); close(input); close(output); end. First, remove the read and write in the txt files, you need to read/write from/to the console. You'll get WA3 now. Try to re-think the case when n=1; the answer is not always 1! Edited by author 19.12.2012 04:05 wrong test 4? 1837, why? Edited by author 19.12.2012 04:06 Edited by author 19.12.2012 04:06 Edited by author 19.12.2012 04:06 Edited by author 19.12.2012 04:07 Edited by author 19.12.2012 04:10 I can't realize what my problem is! #1 must be the simplest test case ( or the sample given ) but I can't see anything in my code that seems to be wrong... can YOU help me? I also have a WA #1 Did you find the problem? my problem is using fflush(stdin) after cin>>n ;(n= number of team), When I delete "fflush(stdin);" , I would pass #1. But I have problem with #9. Haha... I got AC as I changed all ints to longs. I thought ints would be sufficient to do the sum. Still can't figure out why longs are needed. could you explain me test and answer? i can't understand how this situation may happen finally i understood the problem. solution is much easier than it's problem. the problem's solution is very easy: to find min: min[i] = i -count of a[j] where{j<i and a[j]>a[i]} to find max: max[i] = n -count of a[j] where{j>i and a[j]>a[i]} good luck! Much more harger and so important is to prove the result. here is my solution, i don't know why it is not correct and i always wa at #6 lowest: min[i] = count of a[j] where{j>i and a[j]<a[i]} + 1 highest: max[i] = n - count of a[j] where{j<i and a[j]>a[i]} i need some help, thx. Edited by author 28.10.2008 08:15 finally i understood the problem. solution is much easier than it's problem. the problem's solution is very easy: to find min: min[i] = i -count of a[j] where{j<i and a[j]>a[i]} to find max: max[i] = n -count of a[j] where{j>i and a[j]>a[i]} good luck! I think there are some mistakes in your code. For other: Don't look at this code. Think yourself (As I) :) You are right,that anwer got Wa6 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 |
|