Common BoardWhat is 'positive integer'? 0?Of couse not. So: Input:0 Output:10(not 0) Because 0 isn't a positive number But: Input:1 Output:1 Edited by author 24.08.2007 15:16 As I understand the jeep leaving the beginning of the road can take an infinite amount of fuel - M liters in the fuel tank and the rest in the driver's mouth. Somewhere on the way we can leave some fuel. After that we can return and take this fuel. But why can't we fill up the tank after M kilometers? We have the fuel in the driver's mouth!!! Please, anybody who understand this problem explain why I am wrong. Oh, I'm stupid. I understood the problem later. The jeep can carry only M liters. So, we can take M liters in the beginning, go on distance X, leave Y liters there and return back. So, 2 * X + Y <= M. Next time, we can take these Y liters and actually we would be able to carry M + Y liters. I got Crash (stack overflow) when my solution met it. type ac=array[1..601]of longint; var a,c,mi,lan,ch:ac; b,d,e,f,g,h,i,j,k,l,m,n:longint;t:array[1..601]of char; function times(a,c:ac;n:longint):ac; var i,j,l:longint; begin fillchar(ch,sizeof(ch),0); for i:=n downto 1 do begin l:=0; for j:=n downto 1 do if i+j-n>0 then begin ch[i+j-n]:=ch[i+j-n]+a[i]*c[j]+l; l:=ch[i+j-n] div 10; ch[i+j-n]:=ch[i+j-n] mod 10; end; end; times:=ch; end; function larger(a,c:ac;n:longint):boolean; var i:longint; begin for i:=1to n do if a[i]>c[i] then exit(true) else if a[i]<c[i] then exit(false); exit(false); end; procedure goal(g:longint); var i,j:longint; begin if g=602 then begin for i:=601-m+1 to 601 do write(c[i]); WRITELN; halt; end; fillchar(lan,sizeof(lan),0); if odd(n) then for j:=2to (g-(601-m))*2 do LAN[j]:=a[j+(601-n)-1] else for j:=1to (g-(601-m))*2 do LAN[j]:=a[j+(601-n)]; for i:=1to 10 do begin if i<10 then begin c[g]:=i; fillchar(mi,sizeof(mi),0); for j:=1to g-(601-m) do mi[j+g-(601-m)]:=c[j+(601-m)]; mi:=times(mi,mi,(g-(601-m))*2); end; if i=10 then begin c[g]:=9; goal(g+1); end else if larger(mi,lan,(g-(601-m))*2) then begin c[g]:=i-1; goal(g+1); end; end; end; begin n:=0; repeat inc(n); read(t[n]); until eoln; for i:=1to n do a[601-n+i]:=ord(T[I])-48; h:=0; for i:=601 downto 1 do begin a[i]:=a[i]*2+h; h:=a[i] div 10; a[i]:=a[i] mod 10; end; for i:=1to 601 do if a[i]<>0 then break; n:=602-i; m:=(n+1)div 2; goal(601-m+1); end. I think it's OK. Does anybody know what's wrong with it? New tests has been added. 7 authors have lost AC. Edited by author 10.07.2005 23:49 Edited by author 10.07.2005 23:50 I will mail my solution for you ! I accepted in 0.046s and used 337 KB Plz email me... cpp_student@163.com THX PLZ!!!!! I'll appriciated To sort is a quite good way to save time. #include <stdio.h> int main(void) { int n,m,i,p,d; char f[999]; scanf("%d%d",&n,&m); for(p=0;p<n;p++){ f[p]='W'; f[n+1+p]='B'; } f[n]='_'; for(i=0;i<m;i++){ scanf("%d",&p); if(p<0||2*n<p||f[p]=='_'){ printf("error: strange number (%d)\n",p); return 1; } d=(f[p]=='W'?1:-1); if(p+d<0||2*n<p+d){ printf("error: junp to out (%d->%d)\n",p,p+d); return 1; } if(f[p+d]!='_')d*=2; if(p+d<0||2*n<p+d||f[p+d]!='_'){ printf("error: jump to not empty (%d->%d)\n",p,p+d); return 1; } f[p+d]=f[p]; f[p]='_'; // printf("%d->%d\n",p,p+d); } for(p=0;p<=2*n;p++) putchar(f[p]); putchar('\n'); return 0; } Input 4 24 3 5 6 4 2 1 3 5 7 8 6 4 2 0 1 3 5 7 6 4 2 3 5 4 Output BBBB_WWWW Edited by author 22.08.2007 11:51 I have WA and I don't know why. All tests I've done gave me right answers. Somebody, please help me, show me my mistakes!!! Text of program(С++): #include <iostream.h> void main() { short M,N; int j; cout<<"Enter amounts of colors and pieces\n"; cin>>M>>N; cout<<"\nEnter all pieces\n"; short a[500][50]; for (int i=0; i<M; i++) for ( j=0; j<N; j++) cin>>a[i][j]; short t,z,u=0,kolvo=0,p=0,q=0; do { for ( i=0; i<M; i++) for ( j=0; j<N; j++) if(a[i][j]!=(i+1)) { p=j; q=i; if(u==0) t=a[i][j]; else { z=a[i][j]; a[i][j]=t; t=z; } kolvo++;
for (int k=0; k<N; k++) if (a[t-1][k]!=t) { z=a[t-1][k]; a[t-1][k]=t; t=z; u=1; kolvo++; } if (N==1)i=t-2; else i=t-1; j=0;
} }while((i<M)&&(j<N)); if(u==1) kolvo--; cout<<"\nAnswer is="<<kolvo; } You haven't to write some code like cout<<"Enter amounts of colors and pieces\n"; and read FAQ before using Online Judge Thank you, but sill WA on 6th test. =( Try to change short into int>Maybe then you'll get AC. I've already tried to do as you say,but still WA. New tests have been added. 16 authors have lost AC. hello, i try to solve this problem, but i did a mistake..i got WA#3...i think my ideea it's not good. can anyone give me a hint? thx a lot Edited by author 20.02.2007 04:29 Edited by author 20.02.2007 04:29 There is a post with this test on the board) If the input is 4 100 10 120 70 40 150 99 15 400 400 50 160 what's the output and why? this is my code: -------------------------- program t1193; type types=record b:longint; l:longint; e:longint; end; var n,i,start:longint; t:array[0..100]of types; procedure qsort(l,r:integer); var j,i,x,y:integer; begin i:=l;j:=r; x:=t[(l+r) div 2].b; repeat while t[i].b<x do inc(i); while t[j].b>x do dec(j); if i<=j then begin y:=t[i].b; t[i].b:=t[j].b; t[j].b:=y; y:=t[i].e; t[i].e:=t[j].e; t[j].e:=y; y:=t[i].l; t[i].l:=t[j].l; t[j].l:=y; inc(i);dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin readln(n); for i:=1 to n do readln(t[i].b,t[i].l,t[i].e); qsort(1,n); start:=t[1].b; for i:=1 to n do begin start:=start+t[i].l; if t[i+1].b>start then start:=t[i+1].b; end; start:=start-t[n].e; if start>0 then writeln(start) else writeln('0'); end. In the problem write T1<=T3 and you write "400 50 160" it is wrong. sorry my english is very bad import java.io.*; import java.util.*; public class misol { public static void main(String args[]) throws IOException { Scanner sc=new Scanner(System.in); PrintWriter pw=new PrintWriter(System.out); String b="abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ"; String s=""; while (sc.hasNext()) { s=sc.nextLine(); s+=" "; int n=s.length(); String d=""; String w=""; for (int i=0;i<n;i++) { d=s.substring(i,i+1); if (b.indexOf(d)<0) { pw.print(w+d); w=""; } else { w=d+w; } } pw.println(); } pw.close(); sc.close(); } } Please, help me Edited by author 20.08.2007 17:46 Edited by author 20.08.2007 17:47 I thing in this problem impossible get WA. TLE I understand. But... What wrong. I use Qsort and dihotomy. Can anyone give me some interesting tests? Thank's! ;) I have a one question. What here does dichotomy? It here is not necessary :) Maybe you don't understand this task? Try to read again ;) Thank you, Stas! Now I've got AC. In my first solution I use binary find[why not dichotomy?!] But after getting TLE, i see next - "More than half of them are the same." :) It's really fanny task! What is the problem meaning? My english is bad. I can't catch it! Some Chinese friends plz help me send the problem interpretation to this E-mail address: yezhiqi55@126.com OR yezhiqi55@gmail.com Thank you! Edited by author 20.04.2007 11:28 7+1+5<>0+6+8!!! Why did the answer said it is true??? "the previous or the next ticket is lucky"? i.e. ( (715067 is LUCKY) or (715069 is LUCKY)) A ticket is considered lucky if the sum of its first three digits equals the sum of its last three digits. Edited by author 29.04.2007 10:55 7+1+5<>0+6+8!!! Why did the answer said it is true??? 7+1+5<>0+6+8 <=>7+1+1+6+8 <=>23 <=>TRUE For you are a chinese I will give you my algo cpp_student@163.com How many times can I use one of the words Who has some STRANGE test case? What is "Compilation error"? It seems that there's nothing wrong with my program. type ac=array[1..100]of longint; var a,c:array[0..1000]of ac;b,d,e,f,g,h,i,j,k,l,m,n:longint; function add(a,c:ac):ac; var i,j:longint; begin j:=0; for i:=100 downto 1 do begin add[i]:=a[i]+c[i]+j; j:=add[i] div 10; add[i]:=add[i] mod 10; end; end; function times(a,c:ac):ac; var i,j,l:longint; begin fillchar(times,sizeof(times),0); for i:=100 downto 1 do begin l:=0; for j:=100 downto 1 do if i+j-100>0 then begin times[i+j-100]:=times[i+j-100]+a[i]*c[j]+l; l:=times[i+j-100] div 10; times[i+j-100]:=times[i+j-100] mod 10; end; end; end; procedure out(a:ac); var i,j:longint; begin for i:=1to 100 do if a[i]<>0 then break; for j:=i to 100 do write(a[j]); writeln; end; begin read(m,n); if (n mod 2=1)or(m*2*9<n) then writelN('0') else begin fillchar(a,sizeof(a),0); a[0,100]:=1; for i:=1to n do begin c:=a; fillchar(a,sizeof(a),0); for j:=1to m do for l:=0to 9 do if j>=l then a[j]:=add(a[j],c[j-l]); end; out(times(a[m],a[m])); end; end. My compiler says "Error: Not enough actual parameters" >> add[i]:=a[i]+c[i]+j; >> fillchar(times,sizeof(times),0); I've submitted the following solution, and it got AC: #include <cstdio> int main(void) { int N; scanf("%d", &N); if (N==1) { printf("3\n2 0 1\n"); } else { printf("0\n"); } return 0; } Probably, this is a bug in checker Fine problem but unexpected WA42. It may be bug of judj validator also because of very many ways to build right net and therefore using undirect verification of our answers. My prog gives 1. n<3 or m<3-Imaginary 2. n=2*k+1 and m=2*l+1- Imaginary 3. n==3 and m<=7-Imaginary 4. n<=7 and m==3- Imaginary 5. Other cases: Regular and symmetric pictures with obvious correctness Soon I will use Inverse program 40 Islands -1419 Fine problem but unexpected WA42. It may be bug of judj validator also because of very many ways to build right net and therefore using undirect verification of our answers. My prog gives 1. n<3 or m<3-Imaginary 2. n=2*k+1 and m=2*l+1- Imaginary 3. n==3 and m<=7-Imaginary 4. n<=7 and m==3- Imaginary 5. Other cases: Regular and symmetric pictures with obvious correctness Soon I will use Inverse program 40 Islands -1419 Soon I will use Inverse program 40 Islands -1419(I have Ac) as validator of my own and my suspictions will be confirmed Help,please! Who can. Have WA42 But MyAC 1419 Inverse Program confirms all answers in range n,m in [1..50] Eecuse me. Have ac Now Wa42=7*6. Was bug. And Ac 1419 said this but I talked wrong. Ask for AC Code Will send to internet adress under condition that it will be worked with but not used for AC only. #include<iostream> #include<algorithm> using namespace std; int used[500000]={0}; bool cmp(int a,int b) { return (a>b); } int main (void) { int N; cin>>N; for (int k=0;k<N;k++) { int f; cin>>f; used[f]++; } sort (used,used+500000,cmp); cout<<used[0]<<endl; return 0; } WA#7 After fixed #include<iostream> #include<algorithm> using namespace std; struct note { int value; int rank; }; note used[500000]={0}; bool cmp(note a,note b) { return (a.rank>b.rank); } int main (void) { int N,j=0; cin>>N; for (int k=0;k<N;k++) { bool zepo=false; int f; cin>>f; for (int i=0;i<j;i++) if (used[i].value==f) { used[i].rank++; zepo=true; } if (!zepo) { used[j].value=f; used[j].rank=1; } } sort (used,used+j,cmp); cout<<used[0].value<<endl; //cin>>j; return 0; } It's so big...Just create a dynamic array,sort it by sort() function and output n/2-th element of array.Good luck! Edited by author 18.08.2007 14:02 ACed Want my prog? cpp_student@163.com HAHAAAAAA Edited by author 18.08.2007 08:41 Edited by author 18.08.2007 08:41 I am a kind person Do you want AC code?????? |
|