12008 - Emotional Bishop

All about problems in Volume 120. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Sawon90
New poster
Posts: 11
Joined: Wed Nov 23, 2011 1:28 am

12008 - Emotional Bishop

Post by Sawon90 » Mon Mar 19, 2012 3:29 pm

Please help me why I am getting wrong answer.... Is there any critical case??? Someone please help me and give me some Input and Output. My code is

Code: Select all

#include<stdio.h>
int main()
{
	long x1,x2,y1,y2,x,y,t,c,r,cas=1;
	bool fg;
	scanf("%ld",&t);
	while(t--)
	{
		scanf("%ld%ld",&r,&c);
		scanf("%ld%ld%ld%ld",&x1,&y1,&x2,&y2);
		fg=0;
		if(x1<1||x1>r||x2<1||x2>r||y2<1||y2>c||y1<1||y1>c)
			printf("Case %ld: impossible\n",cas++);
		else
		{
			if((x1%2==y1%2 && x2%2==y2%2)||(x1%2!=y1%2 && x2%2!=y2%2))
				fg=1;
			if(!fg)
				printf("Case %ld: impossible\n",cas++);
			else
			{
				x=x1-x2;
				y=y1-y2;
				if(x<0)
					x=-x;
				if(y<0)
					y=-y;
				if(x==0 && y==0)
					printf("Case %ld: 0\n",cas++);
				else if(x==y)
					printf("Case %ld: 1\n",cas++);
				else
					printf("Case %ld: 2\n",cas++);
			}
		}
	}
	return 0;
}

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

Re: 12008 Emotional Bishop

Post by brianfry713 » Mon Mar 19, 2012 11:19 pm

I haven't solved this one yet but this case would take more than 2 moves:
1
2 1000 1 1 2 1000
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 120 (12000-12099)”