## 11494 - Queen

Moderator: Board moderators

bleedingeyes
New poster
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

### 11494 - Queen

what wrong with my logic?
why WA?

Code: Select all

``````//got AC
``````
Last edited by bleedingeyes on Thu Sep 25, 2008 4:19 am, edited 1 time in total.
wanna be notorious....

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### Re: 11494 - Queen

Try this input

edit:
invalid test case removed
Last edited by helloneo on Tue Oct 14, 2008 2:09 pm, edited 1 time in total.

bleedingeyes
New poster
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

### Re: 11494 - Queen

thanx helloneo
i forgot the case where queen can mone straight. not diagonal
i got AC now
thank you very much
wanna be notorious....

kangroo
New poster
Posts: 13
Joined: Fri Sep 12, 2008 9:12 am

### 11494 - Queen - doubt in input !!

hi everybody,

is the test case provided by "helloneo" 1 0 2 0 a valid one ??
in the problem desc its given tat 1 <= X1,Y1,X2,Y2 <= 8...
but here Y1 = 0 and Y2 = 0...
how is it posible ???

pls anyone help me to understand that test case...

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### Re: 11494 - Queen - doubt in input !!

kangroo wrote:hi everybody,

is the test case provided by "helloneo" 1 0 2 0 a valid one ??
in the problem desc its given tat 1 <= X1,Y1,X2,Y2 <= 8...
but here Y1 = 0 and Y2 = 0...
how is it posible ???

pls anyone help me to understand that test case...
Oops.. Sorry..
Maybe there is no case like that..

kangroo
New poster
Posts: 13
Joined: Fri Sep 12, 2008 9:12 am

### 11494 - Queen

can anyone provide me some test cases ?...i m getting WA
pls help me!!

New poster
Posts: 25
Joined: Thu Nov 24, 2011 6:32 am

### Re: 11494 - Queen

I've no idea where I've gone wrong in the logic..getting WA in Queen;please,can anyone help me?

Code: Select all

``````#include<stdio.h>
int absolute(int x)
{
if(x<0) return x*(-1);
else return x;
}
int main()
{
int x1,y1,x2,y2,move;
while(1)
{
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
if((x1==0) && (y1==0) && (x2==0) && (y2==0)) break;
if((x1==x2) && (y1==y2)) move=0;
else if((x1==x2) && (y1=!y2)) move =1;
else if((x1!=x2) && (y1==y2)) move=1;
else if((x1!=x2) && (y1!=y2))
{
if(absolute(x1-x2)==absolute(y1-y2)) move=1;
else move=2;
}
printf("%d\n",move);
}
return 0;
}
``````

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

### Re: 11494 - Queen

In this condition

else if((x1==x2) && (y1=!y2)) move =1;

shouldn't it be y1!=y2 ?

!= and =! aren't the same thing.

engnaruto
New poster
Posts: 2
Joined: Wed Nov 07, 2012 7:41 pm

### Re: 11494 - Queen

i want to know what's wrong with my code

Code: Select all

``````import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
while (input.hasNext()) {

int x1 = input.nextInt();
int y1 = input.nextInt();
int x2 = input.nextInt();
int y2 = input.nextInt();

if (x1 > 8 || x1 < 0 || x2 > 8 || x2 < 0 || y1 > 8 || y1 < 0
|| y2 > 8 || y2 < 0) {
System.exit(0);
} else if (x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) {

System.exit(0);

} else if ((Math.abs(x1 - x2) == Math.abs(y1 - y2))
|| ((x1 - x2) == 0) || ((y1 - y2) == 0)) {

System.out.println(1);

} else if ((x1 == x2) && (y1 == y2)) {

System.out.println(0);

} else {
System.out.println(2);

}

}

}
}``````

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11494 - Queen

It doesn't match the sample I/O.
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 11494 - Queen

That is AC code
Check input and AC output for thousands of problems on uDebug!

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

### Re: 11494 - Queen

Here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

``````1 8 8 8
1 5 6 1
3 7 2 8
5 5 8 8
8 3 8 3
8 3 6 1
1 3 3 1
7 8 7 1
0 0 0 0``````
AC Output:

Code: Select all

``````1
2
1
1
0
1
1
1``````
Check input and AC output for over 7,500 problems on uDebug!