Page 1 of 6

10196 - Check The Check

Posted: Tue Jun 18, 2002 7:56 pm
by Rossi
whats the problem with this one ???????? i'm tired of it

[cpp]
#include<stdio.h>
#include<string.h>

enum {B=0,W};

int drR[]={1,0,-1, 0};
int dcR[]={0,1, 0,-1};

int drB[]={ 1,1,-1,-1};
int dcB[]={-1,1, 1,-1};

int drN[]={ 1, 2,2,1,-1,-2,-2,-1};
int dcN[]={-2,-1,1,2, 2, 1,-1,-2};

int drQ[]={1,0,-1, 0, 1,1,-1,-1};
int dcQ[]={0,1, 0,-1,-1,1, 1,-1};

int isinside(int row,int col)
{return (row>=0&&row<=7&&col>=0&&col<=7)?1:0;}

int chkP(int,int,int);
int chkR(int,int,int);
int chkB(int,int,int);
int chkQ(int,int,int);
int chkN(int,int,int);

char board[8][9];

int main(void)
{
register int i,j;
int set,out,bkr,bkc,wkr,wkc,bnchk,wnchk;

for(set=0;;){
for(i=out=0;i<8;i++){
gets(board);
for(j=0;j<8;j++){
out+=(board[j]=='.')?1:0;
if(board[j]=='k'){
bkr=i;
bkc=j;
}
if(board[j]=='K'){
wkr=i;
wkc=j;
}
}
}
if(out==64)
break;

gets(board[0]);
printf("Game #%d: ",++set);

bnchk=wnchk=0;

bnchk+=chkP(B,bkr,bkc);
wnchk+=chkP(W,wkr,wkc);

bnchk+=chkR(B,bkr,bkc);
wnchk+=chkR(W,wkr,wkc);

bnchk+=chkB(B,bkr,bkc);
wnchk+=chkB(W,wkr,wkc);

bnchk+=chkQ(B,bkr,bkc);
wnchk+=chkQ(W,wkr,wkc);

bnchk+=chkN(B,bkr,bkc);
wnchk+=chkN(W,wkr,wkc);

if(bnchk>0)
printf("black king is in check.\n");
else if(wnchk>0)
printf("white king is in check.\n");
else
printf("no king is in check.\n");
}
return 0;
}

int chkP(int color,int row,int col)
{
register int i;
int tr,tc;

if(color==B){
for(i=0;i<2;i++){
tr=row+drB;
tc=col+dcB;
if(isinside(tr,tc)&&board[tr][tc]=='P')
return 1;
}
}
else{
for(i=2;i<4;i++){
tr=row+drB;
tc=col+dcB;
if(isinside(tr,tc)&&board[tr][tc]=='p')
return 1;
}
}
return 0;
}

int chkR(int color,int row,int col)
{
register int i,j;
int tr,tc;
char comp=(color==B)?'R':'r';

for(i=0;i<4;i++){
tr=row;
tc=col;
do{
tr+=drR;
tc+=dcR;
}while(isinside(tr,tc)&&board[tr][tc]=='.');
if(isinside(tr,tc)&&board[tr][tc]==comp)
return 1;
}
return 0;
}

int chkB(int color,int row,int col)
{
register int i,j;
int tr,tc;
char comp=(color==B)?'B':'b';

for(i=0;i<4;i++){
tr=row;
tc=col;
do{
tr+=drB[i];
tc+=dcB[i];
}while(isinside(tr,tc)&&board[tr][tc]=='.');
if(isinside(tr,tc)&&board[tr][tc]==comp)
return 1;
}
return 0;
}

int chkQ(int color,int row,int col)
{
register int i,j;
int tr,tc;
char comp=(color==B)?'Q':'q';

for(i=0;i<8;i++){
tr=row;
tc=col;
do{
tr+=drQ[i];
tc+=dcQ[i];
}while(isinside(tr,tc)&&board[tr][tc]=='.');
if(isinside(tr,tc)&&board[tr][tc]==comp)
return 1;
}
return 0;
}

int chkN(int color,int row,int col)
{
register int i,j;
int tr,tc;
char comp=(color==B)?'N':'n';

for(i=0;i<8;i++){
tr=row+drN[i];
tc=col+dcN[i];
if(isinside(tr,tc)&&board[tr][tc]==comp)
return 1;
}
return 0;
}
[/cpp]

I'm wrong too >< ..

Posted: Sat Aug 17, 2002 3:13 pm
by DemonCris
Do I need to consider the move of king? ..
As problem describe, there is no condition as
both the two king in check. Therefore, I don't
consider the move of the king ...
But I got WA ... @@? ...
Is there any special condistion which should be notified? .. thanks for your reply^^ ..

Re: I'm wrong too >< ..

Posted: Mon Oct 14, 2002 5:27 am
by yatsen
DemonCris wrote:Do I need to consider the move of king? ..
As problem describe, there is no condition as
both the two king in check. Therefore, I don't
consider the move of the king ...
But I got WA ... @@? ...
Is there any special condistion which should be notified? .. thanks for your reply^^ ..
You do not need to consider the move of the king.
I think you need to check:
1. input ( I just use scanf("%s",a); )
2. how the chess move (if you are not very careful, it is easy to go wrong)
Good Luck!

Posted: Tue Nov 12, 2002 11:20 am
by Larry
Can someone give me some cases? It passes all the ones I can think of.. but still WA =(

try this one

Posted: Sun Jun 01, 2003 6:28 am
by avlahov
mine failed this case at first:

. . . . . . . .
. . . . . . . .
. . . k . . . .
. . . . . . . .
. B . R . . . .
. . . . . . . .
. . . . . . . .
. K . . . . . .

because i had output for both B and R.
just had to add a couple of break statements and got AC!

HELP WITH PROBLEM 10196

Posted: Sat Jun 28, 2003 4:09 am
by AllanLin
Dear Programmers:


WHY DO I HAVE A COMPLING ERROR.. PLEASE HELP ME


[pascal]
uses crt;
const
ndx : array [1..8] of integer = (-1,+1,+2,+2,-1,+1,-2,-2);
ndy : array [1..8] of integer = (+2,+2,+1,-1,-2,-2,+1,-1);
kdx : array [1..8] of integer = (+1,-1,+0,+0,+1,+1,-1,-1);
kdy : array [1..8] of integer = (+1,-1,+0,+0,+1,-1,+1,-1);
rdx : array [1..4] of integer = (+1,-1,+0,+0);
rdy : array [1..4] of integer = (+0,+0,+1,-1);
bdx : array [1..4] of integer = (+1,+1,-1,-1);
bdy : array [1..4] of integer = (+1,-1,+1,-1);
var
w,b : array [-1..10,-1..10] of char;
wcheck,bcheck : boolean;
function input:integer;
var i,j : integer;
king: integer;
ch : char;
begin
king := 0;
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
read(ch);
w[i,j]:='.';
b[i,j]:='.';

if( ch in [ 'a'..'z' ] )then
begin
w[i,j] := ch;
b[i,j] := '*';
if( ch = 'k')then
begin
b[i,j] := '#';
inc(king);
end;
end
else if( ch in [ 'A'..'Z' ] )then
begin
b[i,j] := ch;
w[i,j] := '*';
if( ch = 'K')then
begin
w[i,j] := '#';
inc(king);
end;
end;
end;
readln;
end;
readln;
input:=king;
end;

var
i,j,k : integer;
x,y : integer;
count : integer;
begin
clrscr;
count :=0;

while(input=2)do
begin
inc(count);
bcheck := false;
wcheck := false;

for i:=1 to 8 do
for j:=1 to 8 do
if( w[i,j] = '#' )then
begin
if( w[i+1,j-1] = 'p' ) or
( w[i+1,j+1] = 'p' ) then
wcheck := true;
for k:=1 to 8 do
if( w[i+kdx[k],j+kdy[k]] = 'k' )then
wcheck := true;
for k:=1 to 8 do
if( w[i+ndx[k],j+ndy[k]] = 'n' )then
wcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['r','q'])then
wcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['b','q'])then
wcheck := true;
end;
end;

for i:=1 to 8 do
for j:=1 to 8 do
if( b[i,j] = '#' )then
begin
if( b[i-1,j-1] = 'P' ) or
( b[i-1,j+1] = 'P' ) then
bcheck := true;
for k:=1 to 8 do
if( b[i+kdx[k],j+kdy[k]] = 'K')then
bcheck := true;
for k:=1 to 8 do
if( b[i+ndx[k],j+ndy[k]] = 'N')then
bcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['R','Q'])then
bcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['B','Q'])then
bcheck := true;
end;
end;

write('Game #',count,': ');
if( bcheck )then writeln('black king is in check.')
else if( wcheck )then writeln('white king is in check.')
else writeln('no king is in check.');
end;
end.
[/pascal]

HELP WITH PROBLEM 10196

Posted: Sat Jun 28, 2003 4:10 am
by AllanLin
Dear Programmers:


WHY DO I HAVE A COMPLING ERROR.. PLEASE HELP ME


[pascal]
uses crt;
const
ndx : array [1..8] of integer = (-1,+1,+2,+2,-1,+1,-2,-2);
ndy : array [1..8] of integer = (+2,+2,+1,-1,-2,-2,+1,-1);
kdx : array [1..8] of integer = (+1,-1,+0,+0,+1,+1,-1,-1);
kdy : array [1..8] of integer = (+1,-1,+0,+0,+1,-1,+1,-1);
rdx : array [1..4] of integer = (+1,-1,+0,+0);
rdy : array [1..4] of integer = (+0,+0,+1,-1);
bdx : array [1..4] of integer = (+1,+1,-1,-1);
bdy : array [1..4] of integer = (+1,-1,+1,-1);
var
w,b : array [-1..10,-1..10] of char;
wcheck,bcheck : boolean;
function input:integer;
var i,j : integer;
king: integer;
ch : char;
begin
king := 0;
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
read(ch);
w[i,j]:='.';
b[i,j]:='.';

if( ch in [ 'a'..'z' ] )then
begin
w[i,j] := ch;
b[i,j] := '*';
if( ch = 'k')then
begin
b[i,j] := '#';
inc(king);
end;
end
else if( ch in [ 'A'..'Z' ] )then
begin
b[i,j] := ch;
w[i,j] := '*';
if( ch = 'K')then
begin
w[i,j] := '#';
inc(king);
end;
end;
end;
readln;
end;
readln;
input:=king;
end;

var
i,j,k : integer;
x,y : integer;
count : integer;
begin
clrscr;
count :=0;

while(input=2)do
begin
inc(count);
bcheck := false;
wcheck := false;

for i:=1 to 8 do
for j:=1 to 8 do
if( w[i,j] = '#' )then
begin
if( w[i+1,j-1] = 'p' ) or
( w[i+1,j+1] = 'p' ) then
wcheck := true;
for k:=1 to 8 do
if( w[i+kdx[k],j+kdy[k]] = 'k' )then
wcheck := true;
for k:=1 to 8 do
if( w[i+ndx[k],j+ndy[k]] = 'n' )then
wcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['r','q'])then
wcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['b','q'])then
wcheck := true;
end;
end;

for i:=1 to 8 do
for j:=1 to 8 do
if( b[i,j] = '#' )then
begin
if( b[i-1,j-1] = 'P' ) or
( b[i-1,j+1] = 'P' ) then
bcheck := true;
for k:=1 to 8 do
if( b[i+kdx[k],j+kdy[k]] = 'K')then
bcheck := true;
for k:=1 to 8 do
if( b[i+ndx[k],j+ndy[k]] = 'N')then
bcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['R','Q'])then
bcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['B','Q'])then
bcheck := true;
end;
end;

write('Game #',count,': ');
if( bcheck )then writeln('black king is in check.')
else if( wcheck )then writeln('white king is in check.')
else writeln('no king is in check.');
end;
end.
[/pascal]

10196 - CHECK THE CHECK

Posted: Sun Jun 29, 2003 3:59 am
by AllanLin
Dear EVERYONE!

I'm am not sure how to send my programs into the ACM grader...

Here is my program from MINESWEEPER , ID # 10189
Please Help me Find out what is Wrong!
its keeps saying Compiner Error :o

[c]
#include<stdio.h>

int m,n;
char field[100][100]={0};
int map [100][100]={0};

main()
{
int i,j;
char ch;

scanf("%d%d",&m,&n);
while(( m != 0) && ( n!=0 ))
{
//RESET//
for(i=0;i<100;i++)
for(j=0;j<100;j++)
{field[j]=0;
map[j]=0;}

//INPUT//
for(i=1;i<=m;i++)
{ scanf("%c",&ch);
for(j=1;j<=n;j++)
scanf("%c",&field[j]);}

//WORK//
for(i=1;i<=m;i++)
for(j=1;j<=n;j++)
if(field[j] == '*')
{ map[i+1][j+0] ++;
map[i+1][j+1] ++;
map[i+1][j-1] ++;
map[i+0][j+1] ++;
map[i+0][j-1] ++;
map[i-1][j+0] ++;
map[i-1][j+1] ++;
map[i-1][j-1] ++;}

//OUTPUT//
for(i=1;i<=m;i++)
{for(j=1;j<=n;j++)
if(field[j] == '*') printf("*");
else printf("%d",map[j]);
printf("\n");}

scanf("%d%d",&m,&n);
}
}[/c]






HELP! AHHHHHHHH! :evil:

Posted: Tue Jul 01, 2003 9:13 pm
by raymond85
try remove uses crt; and clrscr;
it seems that it's not necessary as the question is not asking you to output to screen

i dunno if they allow u to use crt...

Posted: Mon Jul 07, 2003 9:19 am
by Observer
Yes. Cut the "crt" part and you'll no longer get CE (but you'll get WA) :) :D

Posted: Sun Jul 13, 2003 10:23 pm
by bugzpodder
Hi Allan,

Did you forget me, Bugz??

sorry, I dont understand Pascal/C codes (I'm only familar with C++ type input/output and strings),... but dont you think we should meet up sometimes?

-Bugz

10196 : please give me some sample input and output

Posted: Sat Feb 28, 2004 4:17 am
by noname
can any body give me some samples input output

thanx

10196 : check the check WA.. Please explain the logic..

Posted: Mon Mar 01, 2004 6:32 am
by aakash_mandhar

What could be wrong.. I get WA even when i have checked for all the conditions i can think of.. I do not check for kings move because both kings can never be in a check... Please tell me a case where my program fails... or if any of you have a different approach...
Thx
Aakash


[cpp]
# include<iostream.h>

char a[10][10];
int bkx,bky,wkx,wky;
int i,j,x,y;

int main()
{
long long nt=0;
while(1)
{
bkx=bky=wkx=wky=-1;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
{
cin>>a[j];
if(a[j]=='k') {bkx=i;bky=j;}
if(a[j]=='K') {wkx=i;wky=j;}
}
}
if(bkx==-1 && bky==-1 && wkx==-1 && wky==-1) return 1;

cout<<"Game #"<<++nt<<": ";
if(bkx<7 && bky>0 && a[bkx+1][bky-1]=='P') {cout<<"black king is in check.\n";goto end;}
if(bkx<7 && bky<7 && a[bkx+1][bky+1]=='P') {cout<<"black king is in check.\n";goto end;}
if(bkx+2<8 && bky+1<8 && a[bkx+2][bky+1]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx+2<8 && bky-1>=0 && a[bkx+2][bky-1]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx-2>=0 && bky+1<8 && a[bkx-2][bky+1]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx-2>=0 && bky-1>=0 && a[bkx-2][bky-1]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx+1<8 && bky+2<8 && a[bkx+1][bky+2]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx+1<8 && bky-2>=0 && a[bkx+1][bky-2]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx-1>=0 && bky+2<8 && a[bkx-1][bky+2]=='N') {cout<<"black king is in check.\n";goto end;}
if(bkx-1>=0 && bky-2>=0 && a[bkx-1][bky-2]=='N') {cout<<"black king is in check.\n";goto end;}

x=bkx;y=bky;
while(1)
{
x++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='R' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}


x=bkx;y=bky;
while(1)
{
x--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='R' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}


x=bkx;y=bky;
while(1)
{
y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='R' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}


x=bkx;y=bky;
while(1)
{
y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='R' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}



x=bkx;y=bky;
while(1)
{
x++;y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='B' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}



x=bkx;y=bky;
while(1)
{
x++;y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='B' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}


x=bkx;y=bky;
while(1)
{
x--;y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='B' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}



x=bkx;y=bky;
while(1)
{
x--;y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='a' && a[x][y]<='z') break;
if(a[x][y]=='B' || a[x][y]=='Q') {cout<<"black king is in check.\n";goto end;}
}

/////////////////////////////
if(wkx>0 && wky>0 && a[wkx-1][wky-1]=='p') {cout<<"white king is in check.\n";goto end;}
if(wkx>0 && wky<7 && a[wkx-1][wky+1]=='p') {cout<<"white king is in check.\n";goto end;}
if(wkx+2<8 && wky+1<8 && a[wkx+2][wky+1]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx+2<8 && wky-1>=0 && a[wkx+2][wky-1]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx-2>=0 && wky+1<8 && a[wkx-2][wky+1]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx-2>=0 && wky-1>=0 && a[wkx-2][wky-1]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx+1<8 && wky+2<8 && a[wkx+1][wky+2]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx+1<8 && wky-2>=0 && a[wkx+1][wky-2]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx-1>=0 && wky+2<8 && a[wkx-1][wky+2]=='n') {cout<<"white king is in check.\n";goto end;}
if(wkx-1>=0 && wky-2>=0 && a[wkx-1][wky-2]=='n') {cout<<"white king is in check.\n";goto end;}
x=wkx;y=wky;
while(1)
{
x++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='r' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}

x=wkx;y=wky;
while(1)
{
x--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='r' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}

x=wkx;y=wky;
while(1)
{
y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='r' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}

x=wkx;y=wky;
while(1)
{
y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='r' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}


x=wkx;y=wky;

while(1)
{
x++;y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='b' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}



x=wkx;y=wky;
while(1)
{
x++;y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='b' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}


x=wkx;y=wky;
while(1)
{
x--;y++;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='b' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}



x=wkx;y=wky;
while(1)
{
x--;y--;
if(x>=8) break;
if(y>=8) break;
if(x<0) break;
if(y<0) break;
if(a[x][y]>='A' && a[x][y]<='Z') break;
if(a[x][y]=='b' || a[x][y]=='q') {cout<<"white king is in check.\n";goto end;}
}

///////////////////////////////

cout<<"no king is in check.\n";
end:
x=bkx;
}

}

[/cpp]

10196 > Critical input/output PLZ!!.

Posted: Thu Mar 18, 2004 9:45 pm
by _.B._
Greetings!.
I've been singing and dancing with this problem, and still can't figure out what's wrong with it.
I've tried this input:

Code: Select all

N......N
........
.k......
........
........
........
........
N......N

n......n
........
........
........
........
......K.
........
n......n

Q......Q
........
........
........
........
........
......k.
Q......Q

q......q
........
........
........
........
........
.K......
q......q

. . . . . . . . 
. . . . . . . . 
. . . k . . . . 
. . . . . . . . 
. B . R . . . . 
. . . . . . . . 
. . . . . . . . 
. K . . . . . .

..k.....
ppp.pppp
........
.R...B..
........
........
PPPPPPPP
K.......

rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR

rnbqk.nr
ppp..ppp
....p...
...p....
.bPP....
.....N..
PP..PPPP
RNBQKB.R

........
........
........
........
........
........
........
........
and works great.
But I got WA!! :cry:
I'm tired of WAs...
I read in a post I don't need to consider to move the Kings, as I already did in my problem, so, what could be wrong?.
Any idea of a critical input/output for this problem?.
Thanks in advance.
_.B._
http://online-judge.uva.es/cgi-bin/Onli ... Info:42085

10196 WA... very confused.

Posted: Fri Apr 09, 2004 3:38 am
by midra
I have no idea of what the program must output if there is a white king adyacent to a black king....who hack?
But for the others case I have make the things well...or that what I think...
Here is my code:

[c]
#include <stdio.h>

int main()
{
int i,x,j,k; /*counters*/
/* i=fila x=columnas*/
int s=1,end=0; /*numero de tablero*/
char board[10][10];
empieza:
end=0,i=x=1;
while(i<=8)
{
scanf("%c", &board[x]);
if (board[x]=='.')
end++;
if (board[x]=='\n')
{
if (end==64)
return 0;
i++;
x=1;
}
else
x++;
}

for (i=1; i<=8; i++)
for (x=1; x<=8; x++)
{
if (board[x]=='K') /*SI HAY KING BLANCO */
{
if (board[i+1][x+1]=='p' || board[i+1][x-1]=='p') /*