ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1125. Hopscotch

I got WA!!! Who can help me?
Posted by Li Xun 12 Apr 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.
Re: I got WA!!! Who can help me?
Posted by Czw's Sister 12 May 2004 09:39
very obvious mistake,there are other numbers fit x*x+y*y=z*z
for example 7*7+24*24=25*25
8*8+15*15=17*17
Li Xun wrote 12 April 2003 18:07
const maxn=50;