Here is what I did to get AC
If a checker has a neighbourhood of the other color than his then I printed his number (and exit);
else "Draw";
neighbourhood of (x,y) are:
(x+1,y+1)
(x+1,y)
(x+1,y-1)
(x,y+1)
(x,y)
(x,y-1)
(x-1,y+1)
(x-1,y)
(x-1,y-1)
I don't see what's the scope of solving such problems. (except learning english :)) )
Re: Here is what I did to get AC
still don't understand.
Could you explain it more?
Re: Here is what I did to get AC
Edited by author 20.10.2004 17:52
Re: Here is what I did to get AC
Edited by author 20.10.2004 18:07
Re: Here is what I did to get AC
According to your statement,I wrote a program and got WA on test 3,could you give me some tests or show me your accpeted code to me?
I don't understand it either. Chesses are only put in black cells, so there are only 4 neighbours for a cell. And there's the boundary! Here's my wa code:
program ural1334;
var
chess:array[0..9,0..9]of boolean;
i,x,y:byte;
a,b:char;
begin
for i:=0 to 9 do begin
chess[0,i]:=true;
chess[9,i]:=true;
end;
for i:=1 to 8 do begin
chess[i,0]:=true;
chess[i,9]:=true;
end;
for i:=1 to 32 do begin
readln(a,b);
x:=ord(a)-96;y:=ord(b)-48;
if (chess[x-1,y-1]<>chess[x+1,y+1]) or (chess[x-1,y+1]<>chess[x+1,y-1]) then begin
writeln(i);
halt;
end;
chess[x,y]:=true;
end;
writeln('Draw');
end.
Edited by author 21.10.2004 10:27
Re: Here is what I did to get AC
ok this is my code:
#include <iostream.h>
#include <stdlib.h>
int a[10][10];
int free(int x,int y)
{
if (a[x-1][y-1]==!a[x][y]) return 0;
if (a[x-1][y+1]==!a[x][y]) return 0;
if (a[x+1][y-1]==!a[x][y]) return 0;
if (a[x+1][y+1]==!a[x][y]) return 0;
if (a[x+1][y]==!a[x][y]) return 0;
if (a[x-1][y]==!a[x][y]) return 0;
if (a[x][y+1]==!a[x][y]) return 0;
if (a[x][y-1]==!a[x][y]) return 0;
return 1;
}
int main()
{
char x,y;
int xx,yy;
int i,j,t;
for (i=0;i<10;i++)
for (j=0;j<10;j++) a[i][j]=-1;
t=0;
while (!cin.eof())
{
t++;
cin>>x>>y;
xx=(int)x-(int)'a'+1;
yy=(int)y-(int)'1'+1;
a[xx][yy]=t%2;
if (!free(xx,yy))
{
cout<<t<<"\n";
exit(0);
}
}
cout<<"Draw\n";
return 0;
}
It's a stupid problem anyway but I got really angry solving it so that's why i show you the solution.
I'm still puzzled. Is the prob statement wrong?
I'm a Pascaler, so I try my best to understand your C prog. It seems that checkers are not only put in the black cells, but in white cells as well, such as A2, B3 and so on. And also, you mean that a checker can only be felled by a checker belonging to the other player. And you think B1 can fell A1, though in this case B1 will jump off the board! Is the prob statement wrong?