Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
实在无语了,怎么也找不出错了.谁找出错了,我请他吃饭(限北京市区)const z: array[0..3] of char=('N','E','S','W'); var i, j, k, temp: longint; n, m: longint; a: array[-1..110,-1..110] of longint; x, y: array[-1..110] of longint; b: array[-1..110] of char; lb, lc: longint; cases, t: longint; flag: boolean; ch: char; p: array['A'..'Z'] of longint; function work(num, t: longint): boolean; var i, j, k: longint; begin case b[num] of 'S': begin k := y[num]; while t>0 do begin dec(t); dec(k); if k<=0 then begin writeln('Robot ',num,' crashes into the wall'); exit(true); end; if a[x[num],k]<>0 then begin writeln('Robot ',num,' crashes into robot ',a[x[num],k]); exit(true); end; end; a[x[num],y[num]] := 0; y[num] := k; a[x[num],y[num]] := num; end; 'E': begin k := x[num]; while t>0 do begin dec(t); inc(k); if k>lb then begin writeln('Robot ',num,' crashes into the wall'); exit(true); end; if a[k,y[num]]<>0 then begin writeln('Robot ',num,' crashes into robot ',a[k,y[num]]); exit(true); end; end; a[x[num],y[num]] := 0; x[num] := k; a[x[num],y[num]] := num; end; 'N': begin k := y[num]; while t>0 do begin dec(t); inc(k); if k>lc then begin writeln('Robot ',num,' crashes into the wall'); exit(true); end; if a[x[num],k]<>0 then begin writeln('Robot ',num,' crashes into robot ',a[x[num],k]); exit(true); end; end; a[x[num],y[num]] := 0; y[num] := k; a[x[num],y[num]] := num; end; 'W': begin k := x[num]; while t>0 do begin dec(t); dec(k); if k<=0 then begin writeln('Robot ',num,' crashes into the wall'); exit(true); end; if a[k,y[num]]<>0 then begin writeln('Robot ',num,' crashes into robot ',a[k,y[num]]); exit(true); end; end; a[x[num],y[num]] := 0; x[num] := k; a[x[num],y[num]] := num; end; end; exit(false); end; begin assign(input,'d:/1.txt'); reset(input); assign(output,'d:/2.txt'); rewrite(output); p['N'] := 0; p['E'] := 1; p['S'] := 2; p['W'] := 3; readln(cases); for t := 1 to cases do begin fillchar(a,sizeof(a),0); readln(lb,lc); readln(n, m); for i := 1 to n do begin readln(x[i],y[i],ch,b[i]); a[x[i],y[i]] := i; end; flag := true; for i := 1 to m do begin readln(k,ch,ch,j); case ch of 'L': begin j := j mod 4; temp := p[b[k]]; temp := (temp+4-j) mod 4; b[k] := z[temp]; end; 'R': begin j := j mod 4; temp := (temp+j) mod 4; b[k] := z[temp]; end; 'F': if work(k,j) then begin flag := false; break; end; end; end; for j := i+1 to m do readln; if flag then writeln('OK'); end; close(input); close(output); end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator