10849 - Move the bishop

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

Moderator: Board moderators

Prianka
New poster
Posts: 6
Joined: Fri Jul 04, 2008 4:06 pm
Location: Dhaka,Bangladesh.

Re: 10849 - Move the bishop

Post by Prianka »

Many many thanks to Maruf.
But it is just a stupid joke nothing else.
If there is no newline so why the judges gave this condition-------
he input begins with a single integer, C, indicating the number of test cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive test cases.
Any way thanks again to help me a lot.
Thanks.
Nothing is impossible............
abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 10849 - Move the bishop

Post by abid_iut »

what is the problem in this code
I think it goes with the algorithm given in previous threads.
here is the code:

Code: Select all

#include<stdio.h>

int main()
{
	long x1,y1,x2,y2,n,num,N;
	scanf("%ld",&n);
	for(int it=0;it<n;it++){
		scanf("%ld",&num);
		scanf("%ld",&N);
		for(int i=0;i<num;i++){
			scanf("%ld %ld %ld %ld",&x1,&y1,&x2,&y2);
			if(x1 == x2 == y1 == y2){printf("0\n");continue;}
			else if(x1==y1 && x2==y2){printf("1\n");continue;}
			if((((x1+y1)%2==0) && ((x2+y2)%2==0)) || (((x1+y1)%2==1) && ((x2+y2)%2==1))){
				if(x1+y1 == x2+y2)printf("1\n");
				else printf("2\n");
			}
			else printf("no move\n");
		}
	}
	return 0;
}

pls help :(
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/
helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 10849 - Move the bishop

Post by helloneo »

Try this case..

Code: Select all

1

1
4
1 2 2 3
My output is

Code: Select all

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

Re: 10849 - Move the bishop

Post by uDebug »

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

Input:

Code: Select all

2

3
100000000
3 6 3 6
100000000 100000000 1 1
56724 9862 8746 190234

20
8
5 5 3 8
5 5 8 3
5 5 7 7
5 5 4 4
6 6 2 7
6 6 7 2
6 6 1 1
6 6 4 4
2 7 2 2
2 7 3 3
2 7 8 1
2 7 1 8
5 8 2 2
5 8 7 7
5 8 3 2
5 8 8 1
6 1 1 6
5 5 8 8
3 4 1 2
7 6 8 4
AC Output:

Code: Select all

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

Find us on Facebook. Follow us on Twitter.
axelblaze
New poster
Posts: 34
Joined: Mon Jun 23, 2014 7:45 pm

Re: 10849 - Move the bishop

Post by axelblaze »

I have no idea why I'm getting WA... :cry: :cry:
Please help. thanks in advance..!

Code: Select all

removed after ac
Last edited by axelblaze on Fri Aug 08, 2014 2:50 am, edited 1 time in total.
waheed
New poster
Posts: 6
Joined: Mon Jul 07, 2014 5:55 pm

10849 - Move the bishop

Post by waheed »

i get WA with this code help plz

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
public static void main (String [] args) throws NumberFormatException, IOException{
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(buffer.readLine());
buffer.readLine();
int s ;
int t ;
int u ;
int v ;
for(int i = 0;i<n;i++){
int x = Integer.parseInt(buffer.readLine());
int y = Integer.parseInt(buffer.readLine());
for(int j = 0;j<x;j++){
StringTokenizer f =new StringTokenizer(buffer.readLine());
int a = Integer.parseInt(f.nextToken());
int b = Integer.parseInt(f.nextToken());
int c = Integer.parseInt(f.nextToken());
int d = Integer.parseInt(f.nextToken());
s = a+b;
t = c+d;
u = a-b;
v = c-d ;
if((s%2==0 && t%2!=0)||(s%2!=0 && t%2==0) )
System.out.println("no move");
else
if(s!=t && u!=v)
System.out.println(2);
else
System.out.println(1);

}
buffer.readLine();

}

}

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

Re: 10849 - Move the bishop

Post by uDebug »

axelblaze wrote:I have no idea why I'm getting WA... :cry: :cry:
Please help. thanks in advance..!
Try running the test case on the post above yours and do a diff of the output files. (Hint: You're printing extra newlines.)
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10849 - Move the bishop

Post by lighted »

If there is a thread about your problem, please use it.
Don't open new thread. Use search first by problem number (10849 for this problem)
http://acm.uva.es/board/search.php?keyw ... 45b4825c8d

For this problem there is existing thread
http://acm.uva.es/board/viewtopic.php?f ... 45b4825c8d
You can check your program for input/output tests posted here.

Also you must post for this problem in the Volume CVIII.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
waheed
New poster
Posts: 6
Joined: Mon Jul 07, 2014 5:55 pm

Re: 10849 - Move the bishop

Post by waheed »

done :D
Last edited by waheed on Sun Jul 20, 2014 2:55 am, edited 1 time in total.
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10849 - Move the bishop

Post by uDebug »

waheed wrote:i fed up with this problem ,i have no idea why i get WA HELP PLZZZZ
Use code tags to make your code more readable.

Also, try moving the "buffer.readLine();" inside the for loop like so

Code: Select all

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader buffer = new BufferedReader(new InputStreamReader(
				System.in));
		long n = Long.parseLong(buffer.readLine());
		long s;
		long t;
		long u;
		long v;
		for (int i = 0; i < n; i++) {
			// Moved readline inside for loop
			buffer.readLine();
			long x = Long.parseLong(buffer.readLine());
			long y = Long.parseLong(buffer.readLine());
			...
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10849 - Move the bishop

Post by lighted »

Are you fed up with getting Accepted?
I got accepted by sending your java solution.
What is your problem? Check it once again. :wink:
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
waheed
New poster
Posts: 6
Joined: Mon Jul 07, 2014 5:55 pm

Re: 10849 - Move the bishop

Post by waheed »

ops :oops: i don't what happenend it is a miracle i run it thousand times and didn't work now it works any way thaaaaaaaaaaaaaaaaaaanks :D :D :D :D :D
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10849 - Move the bishop

Post by lighted »

It will be good if you remove your code after getting accepted
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10849 - Move the bishop

Post by uDebug »

lighted wrote:It will be good if you remove your code after getting accepted
You said it! A significant percentage of people post code when asking for help and then leave it on there once they've figured out the solution. The forum is full of nearly AC (or even AC) code like that. Requesting people to remove their code hardly every works. But perhaps it's worth trying.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10849 - Move the bishop

Post by lighted »

I hope it will help to those people who will solve problems on uva for a long time. :wink:
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
Post Reply

Return to “Volume 108 (10800-10899)”