|
|
back to boardWhat's wrong with this code? (mail: vlad_io1@yahoo.com) var value:array[0..100000] of longint; prev:array[0..100000] of word; top:array[0..1000] of word; n,i,j,k,c:longint; s:string; begin {assign(input,'input.txt'); reset(input);} readln(n); fillchar(prev,sizeof(prev),0); fillchar(top,sizeof(top),0); for i:=1 to n do begin readln(s); if pos('PUSH',s)<>0 then begin delete(s,1,5); val(copy(s,1,pos(' ',s)-1),j,c); delete(s,1,pos(' ',s)); val(s,k,c); value[i]:=k; prev[i]:=top[j]; top[j]:=i; end else begin delete(s,1,4); val(s,j,c); writeln(value[top[j]]); top[j]:=prev[top[j]]; end; end; end. Re: Check your mail (-) Thank you, I got AC now! Re: Can you tell me why I got WA? Posted by ACer 11 Jul 2003 21:07 var i,j,n,l,k,t,zhen:longint; ch:char; a:array[0..100001]of longint; b:array[0..100000]of word; begin readln(n); fillchar(a,sizeof(a),0); fillchar(b,sizeof(b),0); zhen:=1; for i:=1 to n do begin for j:=1 to 2 do read(ch); if ch='o' then begin read(ch);read(ch); readln(t); for j:=zhen-1 downto 1 do if b[j]=t then begin writeln(a[j]); b[j]:=-1000; break; end; end else begin read(ch);read(ch);read(ch);read(t); b[zhen]:=t; readln(t); a[zhen]:=t; inc(zhen); end; end; end. |
|
|