### 11494 - Queen

Posted:

**Thu Sep 25, 2008 2:23 am**The Online Judge board

https://uva.onlinejudge.org/board/

https://uva.onlinejudge.org/board/viewtopic.php?f=42&t=42344

Page **1** of **1**

Posted: **Thu Sep 25, 2008 2:23 am**

Posted: **Thu Sep 25, 2008 2:34 am**

Try this input

edit:

invalid test case removed

edit:

invalid test case removed

Posted: **Thu Sep 25, 2008 4:19 am**

thanx **helloneo**

i forgot the case where queen can mone straight. not diagonal

i got AC now

thank you very much

i forgot the case where queen can mone straight. not diagonal

i got AC now

thank you very much

Posted: **Tue Oct 14, 2008 12:30 pm**

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...

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...

Posted: **Tue Oct 14, 2008 2:05 pm**

Oops.. Sorry..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...

Maybe there is no case like that..

Posted: **Tue Oct 14, 2008 4:19 pm**

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

pls help me!!

thanks in advance..

pls help me!!

thanks in advance..

Posted: **Mon Nov 28, 2011 6:01 pm**

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;
}
```

Posted: **Tue Nov 29, 2011 5:00 am**

In this condition

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

shouldn't it be y1!=y2 ?

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

shouldn't it be y1!=y2 ?

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

Posted: **Wed Nov 07, 2012 7:45 pm**

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);
}
}
}
}
```

Posted: **Wed Nov 07, 2012 10:18 pm**

It doesn't match the sample I/O.

Posted: **Tue Dec 03, 2013 3:10 am**

That is AC code

Posted: **Wed Mar 12, 2014 8:33 am**

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

Input:
AC Output:

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
```

Code: Select all

```
1
2
1
1
0
1
1
1
```