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 1060. Flip Game

Show all messages Hide all messages

Why compilation error??? Yarik 6 Jan 2003 00:30
My program got compilation error, but i can compile it at my computer
without any problems. Why???

var
a, b: array[0..5, 0..5]of boolean;
p: array[1..16]of longint;
i, j, s, min: longint;
st: string;
go: boolean;
begin
for i:=1 to 4 do
begin
  readln(st);
  for j:=1 to 4 do
  if st[j]='b' then a[i, j]:=true
  else a[i, j]:=false;
end;
min:=17;
for p[1]:=0 to 1 do
for p[2]:=0 to 1 do
for p[2]:=0 to 1 do
for p[4]:=0 to 1 do
for p[5]:=0 to 1 do
for p[6]:=0 to 1 do
for p[7]:=0 to 1 do
for p[8]:=0 to 1 do
for p[9]:=0 to 1 do
for p[10]:=0 to 1 do
for p[11]:=0 to 1 do
for p[12]:=0 to 1 do
for p[13]:=0 to 1 do
for p[14]:=0 to 1 do
for p[15]:=0 to 1 do
for p[16]:=0 to 1 do
begin
  for i:=1 to 4 do
  for j:=1 to 4 do
  b[i, j]:=a[i, j];
  for i:=1 to 16 do
  if p[i]=1 then
  begin
    b[(i-1) mod 4+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1, (i-1) div
4+1];
    b[(i-1) mod 4+1+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1+1, (i-1)
div 4+1];
    b[(i-1) mod 4+1-1, (i-1) div 4+1]:=not b[(i-1) mod 4+1-1, (i-1)
div 4+1];
    b[(i-1) mod 4+1, (i-1) div 4+1+1]:=not b[(i-1) mod 4+1, (i-1) div
4+1+1];
    b[(i-1) mod 4+1, (i-1) div 4+1-1]:=not b[(i-1) mod 4+1, (i-1) div
4+1-1];
  end;
  go:=true;
  for i:=1 to 4 do
  for j:=1 to 4 do
  if not b[i, j] then go:=false;
  if go then s:=p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+p[8]+p[9]+p[10]+p
[11]+
  p[12]+p[13]+p[14]+p[15]+p[16];
  if (s<min) and (go) then min:=s;
end;
if min<17 then writeln(min)
else writeln('Impossible');
end.
Re: Why compilation error??? Oleg 9 Jan 2003 06:39
> My program got compilation error, but i can compile it at my
computer
> without any problems. Why???
>
> var
> a, b: array[0..5, 0..5]of boolean;
> p: array[1..16]of longint;
> i, j, s, min: longint;
> st: string;
> go: boolean;
> begin
> for i:=1 to 4 do
> begin
>   readln(st);
>   for j:=1 to 4 do
>   if st[j]='b' then a[i, j]:=true
>   else a[i, j]:=false;
> end;
> min:=17;
> >>>>for p[1]:=0 to 1 do
> for p[2]:=0 to 1 do
> for p[2]:=0 to 1 do
> for p[4]:=0 to 1 do
> for p[5]:=0 to 1 do
> for p[6]:=0 to 1 do
> for p[7]:=0 to 1 do
> for p[8]:=0 to 1 do
> for p[9]:=0 to 1 do
> for p[10]:=0 to 1 do
> for p[11]:=0 to 1 do
> for p[12]:=0 to 1 do
> for p[13]:=0 to 1 do
> for p[14]:=0 to 1 do
> for p[15]:=0 to 1 do
> for p[16]:=0 to 1 do<<<<< HERE IS CE
> begin
>   for i:=1 to 4 do
>   for j:=1 to 4 do
>   b[i, j]:=a[i, j];
>   for i:=1 to 16 do
>   if p[i]=1 then
>   begin
>     b[(i-1) mod 4+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1, (i-1) div
> 4+1];
>     b[(i-1) mod 4+1+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1+1, (i-1)
> div 4+1];
>     b[(i-1) mod 4+1-1, (i-1) div 4+1]:=not b[(i-1) mod 4+1-1, (i-1)
> div 4+1];
>     b[(i-1) mod 4+1, (i-1) div 4+1+1]:=not b[(i-1) mod 4+1, (i-1)
div
> 4+1+1];
>     b[(i-1) mod 4+1, (i-1) div 4+1-1]:=not b[(i-1) mod 4+1, (i-1)
div
> 4+1-1];
>   end;
>   go:=true;
>   for i:=1 to 4 do
>   for j:=1 to 4 do
>   if not b[i, j] then go:=false;
>   if go then s:=p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+p[8]+p[9]+p[10]+p
> [11]+
>   p[12]+p[13]+p[14]+p[15]+p[16];
>   if (s<min) and (go) then min:=s;
> end;
> if min<17 then writeln(min)
> else writeln('Impossible');
> end.
>
Re: Why compilation error??? Dick162 19 Jan 2003 12:11
> My program got compilation error, but i can compile it at my
computer
> without any problems. Why???
>
> var
> a, b: array[0..5, 0..5]of boolean;
> p: array[1..16]of longint;
> i, j, s, min: longint;
> st: string;
> go: boolean;
> begin
> for i:=1 to 4 do
> begin
>   readln(st);
>   for j:=1 to 4 do
>   if st[j]='b' then a[i, j]:=true
>   else a[i, j]:=false;
> end;
> min:=17;
> for p[1]:=0 to 1 do
> for p[2]:=0 to 1 do
> for p[2]:=0 to 1 do
> for p[4]:=0 to 1 do
> for p[5]:=0 to 1 do
> for p[6]:=0 to 1 do
> for p[7]:=0 to 1 do
> for p[8]:=0 to 1 do
> for p[9]:=0 to 1 do
> for p[10]:=0 to 1 do
> for p[11]:=0 to 1 do
> for p[12]:=0 to 1 do
> for p[13]:=0 to 1 do
> for p[14]:=0 to 1 do
> for p[15]:=0 to 1 do
> for p[16]:=0 to 1 do
> begin
>   for i:=1 to 4 do
>   for j:=1 to 4 do
>   b[i, j]:=a[i, j];
>   for i:=1 to 16 do
>   if p[i]=1 then
>   begin
>     b[(i-1) mod 4+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1, (i-1) div
> 4+1];
>     b[(i-1) mod 4+1+1, (i-1) div 4+1]:=not b[(i-1) mod 4+1+1, (i-1)
> div 4+1];
>     b[(i-1) mod 4+1-1, (i-1) div 4+1]:=not b[(i-1) mod 4+1-1, (i-1)
> div 4+1];
>     b[(i-1) mod 4+1, (i-1) div 4+1+1]:=not b[(i-1) mod 4+1, (i-1)
div
> 4+1+1];
>     b[(i-1) mod 4+1, (i-1) div 4+1-1]:=not b[(i-1) mod 4+1, (i-1)
div
> 4+1-1];
>   end;
>   go:=true;
>   for i:=1 to 4 do
>   for j:=1 to 4 do
>   if not b[i, j] then go:=false;
>   if go then s:=p[1]+p[2]+p[3]+p[4]+p[5]+p[6]+p[7]+p[8]+p[9]+p[10]+p
> [11]+
>   p[12]+p[13]+p[14]+p[15]+p[16];
>   if (s<min) and (go) then min:=s;
> end;
> if min<17 then writeln(min)
> else writeln('Impossible');
> end.
>