Page 1 of 1

11494 - Queen

Posted: Thu Sep 25, 2008 2:23 am
by bleedingeyes
what wrong with my logic?
why WA?
please help me

Code: Select all

//got AC

Re: 11494 - Queen

Posted: Thu Sep 25, 2008 2:34 am
by helloneo
Try this input

edit:
invalid test case removed

Re: 11494 - Queen

Posted: Thu Sep 25, 2008 4:19 am
by bleedingeyes
thanx helloneo
i forgot the case where queen can mone straight. not diagonal
i got AC now
thank you very much

11494 - Queen - doubt in input !!

Posted: Tue Oct 14, 2008 12:30 pm
by kangroo
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...

Re: 11494 - Queen - doubt in input !!

Posted: Tue Oct 14, 2008 2:05 pm
by helloneo
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.. :-)

11494 - Queen

Posted: Tue Oct 14, 2008 4:19 pm
by kangroo
can anyone provide me some test cases ?...i m getting WA
pls help me!!
thanks in advance..

Re: 11494 - Queen

Posted: Mon Nov 28, 2011 6:01 pm
by sadia_atique
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;
}

Re: 11494 - Queen

Posted: Tue Nov 29, 2011 5:00 am
by sohel
In this condition

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

shouldn't it be y1!=y2 ?

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

Re: 11494 - Queen

Posted: Wed Nov 07, 2012 7:45 pm
by engnaruto
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);

			}

		}

	}
}

Re: 11494 - Queen

Posted: Wed Nov 07, 2012 10:18 pm
by brianfry713
It doesn't match the sample I/O.

Re: 11494 - Queen

Posted: Tue Dec 03, 2013 3:10 am
by brianfry713
That is AC code

Re: 11494 - Queen

Posted: Wed Mar 12, 2014 8:33 am
by uDebug
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