10849  Move the bishop
Moderator: Board moderators
10849  Move the bishop
Hi:
I just wanted to know if my algorithm was right, 'cause I could not get AC during the contest
1. When abs(f1  f2) == abs(c1  c2) the min number of moves is 1.
2. When odd(f1 + c1) == odd(f2 + c2) the min number of moves is 2.
else no move...
Am i right???, if no, please tell me a counterexample, thanx in advance, frustraded,
Yandry.
I just wanted to know if my algorithm was right, 'cause I could not get AC during the contest
1. When abs(f1  f2) == abs(c1  c2) the min number of moves is 1.
2. When odd(f1 + c1) == odd(f2 + c2) the min number of moves is 2.
else no move...
Am i right???, if no, please tell me a counterexample, thanx in advance, frustraded,
Yandry.
I am trying to go from (sx, sy) to (tx, ty).All coords are long ints.
Removed spoiler...
Code: Select all
if can't move
{
print "no move\n";
}
else
{
/* calculate, what else! */
print #"\n";
}
Last edited by sumankar on Thu May 26, 2005 7:37 am, edited 1 time in total.
This is wrong, I think:What is wrong here?
Code: Select all
if ( (sx+sy+tx+ty)&1L )
Code: Select all
if (((x0 + y0) & 1) != ((x1 + y1) & 1)) {

 Experienced poster
 Posts: 131
 Joined: Sat Jul 17, 2004 4:09 am
 Location: Lima, Per
Hi for all
Just for the record, how is possible this runtime??
Is there any better algorithm or is just an I/O improvement?
Regards
Just for the record, how is possible this runtime??
Code: Select all
1 0:00.006 64 mjf f C 2005/05/2513:17:40.387 3593783 (H0)
Regards
Well what you are doing is checking if the parity of the sum of the x & y coords of the start and end points are same or not. The sums can either be Odd or Even, and if they are same, summing two Odds would give me an even number and so on for the Even sums...which is why I would think the code for no move is correct.mf wrote:This is wrong, I think:What is wrong here?My AC code checks the "no move" case like:Code: Select all
if ( (sx+sy+tx+ty)&1L )
Code: Select all
if (((x0 + y0) & 1) != ((x1 + y1) & 1)) {
Suman.
Small change:mf wrote:... Post your full source.
from
Code: Select all
if ( ((sx+sy+tx+ty)&1L) )
Code: Select all
if ( ((sx+sy+tx+ty)&1L)  (tx>n  ty>n)  (sx<1Lsy<1Lsx>nsy>n))
Last edited by sumankar on Thu May 26, 2005 7:31 am, edited 1 time in total.
mf: Is that my code you are talking about?This is the link I use
http://acm.uva.es/problemset/submit.php.
Thanks for taking all that trouble.
One more thing:tweaked i/o, can you possibly enlighten me a tad bit more?:)
Suman.
http://acm.uva.es/problemset/submit.php.
Thanks for taking all that trouble.
One more thing:tweaked i/o, can you possibly enlighten me a tad bit more?:)
Suman.
10849  Move the bishop
CUT
Last edited by helloneo on Tue May 22, 2007 7:53 am, edited 2 times in total.
10849  Move the bishop
It seems to be a easy problem, but I got WA always.
Is there any tricky I/O ?
Thanks in advance.
Is there any tricky I/O ?
Thanks in advance.
hhh
have you ever thought the 2 bishops are on the same position..?