I got WA!!! Who can help me?
Послано
Li Xun 12 апр 2003 18:07
const maxn=50;
type hl=array[1..maxn] of 0..1;
var data:array[1..maxn,1..maxn] of longint;
f:array[1..maxn,1..maxn] of 0..1;
h,l:hl;
i,j,k,n,m:longint;
color:array[1..maxn,1..maxn] of char;
function min(r,t:longint):longint;
begin
if r<t then min:=r else min:=t
end;
procedure make(x,y:longint);
begin
for k:=min((m-i) div x,(n-j) div y) downto 1 do
f[i+k*x,j+k*y]:=1-f[i+k*x,j+k*y];
for k:=min((m-i) div x,(j-1) div y) downto 1 do
f[i+k*x,j-k*y]:=1-f[i+k*x,j-k*y];
for k:=min((i-1) div x,(j-1) div y) downto 1 do
f[i-k*x,j-k*y]:=1-f[i-k*x,j-k*y];
for k:=min((i-1) div x,(n-j) div y) downto 1 do
f[i-k*x,j+k*y]:=1-f[i-k*x,j+k*y]
end;
begin
assign(input,'input.in'); reset(input);
readln(m,n);
for i:=1 to m do
begin
for j:=1 to n do read(color[i,j]);
readln
end;
for i:=1 to m do for j:=1 to n do read(data[i,j]);
close(input);
fillchar(h,sizeof(h),0); l:=h;
fillchar(f,sizeof(f),0);
for i:=1 to m do
for j:=1 to n do
if odd(data[i,j]) then begin
h[i]:=1-h[i];
l[j]:=1-l[j];
make(3,4); make(4,3); make(5,12); make(12,5)
end;
for i:=1 to m do
begin
for j:=1 to n do
if color[i,j]='W' then if odd(h[i]+l[j]+f[i,j]+data[i,j])
then write('B') else write('W')
else if odd(h[i]+l[j]+f[i,j]+data[i,j]) then write('W')
else write('B');
writeln
end
end.