Общий форумI have Wrong Answer 14. I am testing my program nearly 2 hours and I can't find mistake. who had WA14 please tell me what kind of test is it? please help huh I got AC. very silly mistake :(( Edited by author 24.02.2007 01:11 I had WA 14 too. There is a mistake in my program: one of my functions used the global variables but some of variables shouldn't be global. Now is AC. var a:array[1..10000]of integer; m,n,k,i,j:integer; begin fillchar(a,sizeof(a),0); readln(m,n,k); for i:=k+1 to 10000 do begin for j:=1 to trunc(sqrt(i)) do if i mod j=0 then a[i]:=a[i]+1; if (a[i]=n)and(a[i-k]=m) then begin writeln(i);halt;end; end; end. because your algorithm is wrong Why I have WA #8? I think my program isn't wrong. Some test data can you give me? #include<iostream> #include<vector> #include<cmath> #include<algorithm> #include<string> using namespace std; string sub(string a,string b) { int c=max(a.length(),b.length()); string s1(c-a.length(),'0'),s2(c-b.length(),'0'); s1+=a;s2+=b; int naum=0;string s3;for(int i=c-1;i>=0;i--) { s3+=(s1[i]+s2[i]-96+naum)%10+'0'; naum=(s1[i]+s2[i]-96+naum)/10; } if(naum)s3+=naum+'0'; reverse(s3.begin(),s3.end()); return s3; } string umn(string a,int b) { int naum=0; string c; for(int i=a.length()-1;i>=0;i--) { c+=((a[i]-'0')*b+naum)%10+'0'; naum=((a[i]-'0')*b+naum)/10; } if(naum)c+=naum+'0'; reverse(c.begin(),c.end()); return c; } string umn1(string a,string b) { string c="0"; for(int i=0;i<b.length();i++) { string e(b.length()-i-1,'0'); c=sub(c,umn(a,b[i]-'0')+e); } return c; } string razl(string a,string b) { int c=max(a.length(),b.length()); string s1(c-a.length(),'0'),s2(c-b.length(),'0');s1+=a;s2+=b; int naum=0; string s3; for(int i=s1.length()-1;i>=0;i--) { int a=s1[i]-s2[i]; if(naum){a--;naum=0;} if(a<0){naum=1;a+=10;} s3+=a+'0'; } reverse(s3.begin(),s3.end()); while(s3[0]=='0'&&s3.length()>1)s3.erase(0,1); return s3; } string int_to_str(int n) { string s; while(n){s+=n%10+'0';n/=10;} reverse(s.begin(),s.end()); return s; } int cmp(string a,string b){ if(a==b||a.length()<b.length()||(a.length()==b.length()&&a<b))return 1; return 0; } int main() { /* cout<<sub("112","33")<<endl; cout<<razl("112","33")<<endl; cout<<umn1("112","33")<<endl; */ string s; cin>>s; if(s=="0"){cout<<0<<endl;return 0;} s=umn(s,2); string res; vector<string>a; int j=0; if(s.length()%2==1) { j=1; string m;m+=s[0]; a.push_back(m); } for(int i=j;i<s.length();i+=2) a.push_back(s.substr(i,2)); int x; if(a[0].size()==1)x=a[0][0]-'0';else x=a[0][0]*10+a[0][1]-528; double m=sqrt((double)(x)); int n=(int)(m); res=int_to_str(n); int q=x-n*n; string f; f=int_to_str(q); for(int k=1;k<a.size();k++) { string y=res; int l; y=umn(y,2); f+=a[k]; //cout<<f<<endl; string j[20]; if(f[0]=='0'){res+="0";continue;} char c='0'; j[0]=umn(y+c,c-'0'); //cout<<j[0]<<endl; c='1'; j[1]=umn(y+c,c-'0'); //cout<<j[1]<<endl; if(cmp(j[0],f)==1&&cmp(j[1],f)==0) {res+="0";l=0;} for(int i=2;i<=9;i++) { c=i+'0'; j[i]=umn(y+c,i); //cout<<j[i]<<endl; if(cmp(j[i-1],f)==1&&cmp(j[i],f)==0){res+=i-1+'0';l=i-1;break;} } if(res.length()!=k+1){res+="9";l=9;} f=razl(f,j[l]); } cout<<res<<endl; system("pause");return 0; } I got WA#29 so many times. I can't find the mistakes from my program. By the way,is that something wrong with my "reading" part? Here is my reaing part: procedure init; begin readln(m); for i:=1 to m do begin read(ch); a[i]:=ord(ch); end; readln; end; 250000 AA...A Edited by author 16.03.2009 19:41 And test 30? I reach both memory limit and time limit. #include <iostream> using namespace std; int n,i, j=0,s=0; int*x,*y,*a; int main() { cin>>n; x=new int[n]; y=new int[n]; a=new int[n]; for(i=0; i<n; i++) a[i]=0; for(i=0; i<n; i++) cin>>x[i]>>y[i]; while(j<n) { s=0; for(i=0; i<j; i++) { if(x[i]<=x[j]) s++; } a[s]++; j++; } for(i=0; i<n; i++) cout<<a[i]<<endl; delete []x; delete []y; delete []a; return 0; } tl#13 bgg. use tree =) i dont know tree, pls tell me about that Before sending solution, just test it on this examples. 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 ;) Thank you very much!!!! I've got AC!! HAHA!! Before sending solution, just test it on this examples. 1) 23.42 01.14 08.10 17.51 Answer: 4 2) 01.01 10.59 04.23 04.22 Answer: 5 3) 12.00 15.00 01.02 03.07 Answer: 0 4) 23.58 00.43 22.27 03.10 Answer: 2 5) 12.00 15.00 20.00 21.00 Answer: 1 6) 01.01 21.59 04.23 11.22 Answer: 5 ;) Thanks a lot! It helps me very much. I don't usually plan before writing a program, so I made lots and lots of wrong algorithms. I use your test cases and I correct , correct and recorrect my algorithms. They are wrong and wrong on test 4, 2, 5,.. (your test cases). And I got AC on the 2nd submit! Thank you! 6) 01.01 21.59 04.23 11.22 Answer: 5 why it is true? what is wrong in my& my program: var xh1, xh2, yh1, yh2 : real; xm1, xm2, ym1, ym2 : real; k, km : longint; begin read(xh1, yh1, xh2, yh2); xm1:=trunc(xh1*100) mod 100; xm2:=trunc(xh2*100) mod 100; ym1:=trunc(yh1*100) mod 100; ym2:=trunc(yh2*100) mod 100; if yh1<xh1 then yh1:=yh1+24; if yh2<xh2 then yh2:=yh2+24; xh1:=trunc(xh1); xh2:=trunc(xh2); yh1:=trunc(yh1); yh2:=trunc(yh2); k:=abs(trunc(0.5*(yh1-yh2+xh2-xh1+trunc( (ym1-ym2+xm2-xm1)/60) )) ); writeln(k); end. Thank you a lot. In your test 6 my program outputs 7. I forgot that answer should be than 6. But due to my formula (which,I hope, is correct)the answer is 7. Now I have AC. Thanks! I couldn't get 1 thing for tests 2 and 6. why answer isn't 7? if the real time of flight if 17, for 2 test and 14, for 6 test, then 17-7=10 and 14-7=7 (the differences of flights where time is "going back") and 17+7=24 & 14+7=21 (the differences of flights where time is "goting forward"). but if answer is 5 then 10+5=15 24-5=19 (<>) and 7+5=12 and 21-5=16. then wahy this test are true. I know that there must be something that I didn't saw so please help me. thanks. I'm don't understand, how can it be: 12.00 15.00 01.02 03.07 It means, that in one way plane fly 3 hours, in other - 2 hours. But in terms said, that times differs not more than 10 minutes. This test is INCORRECT! Read this post again. My program Wa3 This is my program: program Ural683; var a,m,n:longint; k:array[0..50]of longint; begin readln(n); m:=1; k[0]:=n; while k[m-1]<>0 do begin k[m]:=k[m-1]shr 1; inc(m); end; m:=0; a:=1; while a<n do begin inc(m);a:=a shl 1; end; writeln(m); for a:=1 to m do if k[a]=0 then write(1,' ') else write(k[a],' '); end. Who can help me? Edited by author 02.04.2009 14:18 Now I am AC!!! program Ural683; var a,m,n:longint; k:array[0..50]of longint; begin readln(n); m:=0; while n<>1 do begin inc(m); n:=n-n shr 1; k[m]:=n; end; writeln(m); for a:=1 to m do write(k[a],' '); end. Can someone please help me with test case #3. I get WA on it, but my solution passes all test cases I made. :\ My program works on sample input and all inputs given in discussion forum. But I am getting WA3. Can anybody please give me direction or this test case? I get WA3 as well, so ca u pls help me? Edited by author 02.04.2009 05:52 Edited by author 02.04.2009 05:52 Mine too, what's the catch ? :( Why does N == 0 in test 2 ? An input contains an integer N (2 ≤ N ≤ 200) ... One blogger can mark another as his friend more than once. Of course, you should print his name in the list of friends only once. Good luck! I believe that after some simplifications can be obtained even faster code Can you give me a hint about TEST#27?I have been checked my program for 2 days.And I can't find what's wrong with my program.I'm crazy! Here is my program: program puzzle; const maxn=410; var d,f:array [0..maxn,0..maxn] of longint; b,e,s,a:array [0..maxn] of longint; t,vis:array [0..maxn] of boolean; ch:array [0..maxn] of char; i,j,p,k,l,m,n:longint; procedure init; begin read(n,m); for i:=1 to m do read(a[i]);readln; for i:=1 to n do begin repeat read(ch[i]); until ch[i] in ['?','X','.']; end; readln; end; procedure solve; begin for i:=1 to n do begin s[i]:=s[i-1]; if ch[i]='X' then inc(s[i]); end; fillchar(d,sizeof(d),-$3f); d[n+1,m+1]:=0; k:=n; for i:=n downto 1 do begin for j:=m+1 downto 1 do begin d[i,j]:=d[i+1,j]; if (j=m+1) or (i+a[j]-1>n) or (ch[i]='.') then continue; if i+a[j]+1>n then l:=n+1 else l:=i+a[j]+1; if (i+a[j]-1<=k) and (d[l,j+1]>=0) and (d[l,j+1]+s[i+a[j]-1]-s[i-1]>d[i,j]) then d[i,j]:=d[l,j+1]+s[i+a[j]-1]-s[i-1]; end; if ch[i]='.' then k:=i-1; end; if d[1,1]<>s[n] then begin writeln('Impossible');exit; end; fillchar(f,sizeof(f),-$3f); f[0,0]:=0; k:=1; for i:=1 to n do begin for j:=0 to m do begin f[i,j]:=f[i-1,j]; if (j=0) or (i<a[j]) or (ch[i]='.') then continue; if i-a[j]-1<1 then l:=0 else l:=i-a[j]-1; if (i-a[j]+1>=k) and (f[l,j-1]>=0) and (f[l,j-1]+s[i]-s[i-a[j]]>f[i,j]) then f[i,j]:=f[l,j-1]+s[i]-s[i-a[j]]; end; if ch[i]='.' then k:=i+1; end; fillchar(vis,sizeof(vis),false); fillchar(t,sizeof(t),false); fillchar(b,sizeof(b),255); p:=0; for i:=1 to n do begin if ch[i]='.' then begin p:=i;continue; end; for j:=1 to m do begin if i-a[j]+1<=p then continue; if i+2<=n then k:=d[i+2,j+1] else begin if j<m then continue;k:=0; end; if i-a[j]-1>0 then inc(k,f[i-a[j]-1,j-1]) else begin if j>1 then continue; end; if s[i]-s[i-a[j]]+k=s[n] then begin for l:=i-a[j]+1 to i do t[l]:=true; if b[j]=-1 then begin b[j]:=i-a[j]+1;e[j]:=i; continue; end; if e[j]<i-a[j]+1 then begin b[j]:=i-a[j]+1;e[j]:=i; vis[j]:=true; end; if vis[j] then continue; b[j]:=i-a[j]+1; end; end; end; for i:=1 to n do if not t[i] and (ch[i]='?') then ch[i]:='.'; for i:=1 to m do begin if vis[i] then continue; for j:=b[i] to e[i] do ch[j]:='X'; end; for i:=1 to n do write(ch[i]);writeln; end; begin assign(input,'puzzle.in');reset(input); assign(output,'puzzle.out');rewrite(output); init; solve; close(input);close(output); end. At last.Sorry for my poor English. A test for you: 8 2 2 2 ??.X?.?? I used greed, is the result of the test data right ? 7 2 3 0 3 1 0 1 2 4 5 0 3 0 3 0 7 0 6 0 4 1 2 3 7 if the result is wrong , please give some hint..... thanks Your result is really wrong. Just take a look: the first and the second mates have no friends in the other team. Edited by author 30.08.2008 15:39 Edited by author 30.08.2008 15:39 Edited by author 30.08.2008 15:39 it's a simple bfs problem. who give AC, please, give me right answers for this tests : 1) 1 200 245 2) 0 13 131 3) 37 39 41 4) 29 41 97 5) 0 64 129 6) 81 27 243 7) 240 241 242 thanx Edited by author 14.08.2008 21:51 1)446 2)15 3)76 4)167 5)7 6)13 7)723 Any Hint? I also have wa#20 Where's mistake? But you've solved it, maybe you'll help me? var i,n:integer; cx,cy,x1,y1,x2,y2,x3,y3,x4,y4:integer; x,y:array[1..102]of integer; h,min,zn,ras1,ras2:real; f:boolean; begin read(cx);read(cy);readln(n); for i:=1 to n do readln(x[i],y[i]); x[n+1]:=x[1];y[n+1]:=y[1]; f:=true; zn:=0; for i:=1 to n do begin x1:=x[i]-cx;y1:=y[i]-cy; x2:=x[i+1]-cx;y2:=y[i+1]-cy; if (zn=0)then begin zn:=x1*y2-x2*y1; if (zn=0)then begin if ((x[i]<=cx)and(cx<=x[i+1]))or((x[i]>=cx)and(cx>=x[i+1]))then f:=true else f:=false; break;break;break; end; end else begin if (zn*(x1*y2-x2*y1)<0)then begin f:=false; break;break;break; end; end; end; if (f=true)then write('0.000') else begin min:=0; f:=false; for i:=1 to n do begin x1:=cx-x[i];y1:=cy-y[i];x2:=x[i+1]-x[i];y2:=y[i+1]-y[i];x3:=cx-x[i+1];y3:=cy-y[i+1];x4:=x[i]-x[i+1];y4:=y[i]-y[i+1]; if (x1*x2+y1*y2>0)and(x3*x4+y3*y4>0)then begin x1:=x[i]-cx;y1:=y[i]-cy;x2:=x[i+1]-cx;y2:=y[i+1]-cy; h:=(abs(x1*y2-x2*y1))/(sqrt(sqr(x[i+1]-x[i])+sqr(y[i+1]-y[i]))); end else h:=0; ras1:=sqrt(sqr(cx-x[i])+sqr(cy-y[i]));ras2:=sqrt(sqr(cx-x[i+1])+sqr(cy-y[i+1])); if (ras2<ras1)then ras1:=ras2; if (ras1<h)or(h=0)then h:=ras1; if (f=false)or(h<min)then begin min:=h; f:=true; end; end; write((2*min):0:3); end; end. Tell me, please, what is the Output for 1) N=4 2) N=10 3) N=3^m (For example, N=27) Please, help... Thanks a lot. Here are my answers but they are not unique I think 4 13 9 10 37 27 9 36 27 27 108 81 81 324 243 Thanks A Lot! I've got AC!!! What formalization? N=a-b; b>0; a and b have no digit 2 in 3-system? Edited by author 30.06.2007 13:50 Edited by author 30.06.2007 13:51 Why 10 37 27? a = 10(10)=101(3) b = 3(10) =010(3) a+b = 13(10)=111(3) IMHO, right ansver is 10 13 3 Can somebody say me, what is in test 10? I don't know, why i got WA... Finally I've got AC. My mistake was, I think, in printing something like "-0.*" when answer is less than epsilon. Hi, My answer to the problem 1002 was having "time limit exceeded" problem and sent for test#5. Can I get the test cases on which you are judging our answers so that I can check if my program is working fine with these cases or what error is coming ??? |
|