Better approach for A: King's Race

Revision en1, by oartihsin, 2020-04-17 17:54:44

black has to travel n-x distance row-wise and n-y distance column wise to reach the coin at (x,y). Hence total distance travelled by black is b = n-x + n-y. Similary white has to travel x-1 distance row wise and y-1 column wise. Total distance travelled by white is w = x-1 + y-1. if(b<w) answer is black. else answer is white(if(w<b) it is obvious ... but if b==w then white reaches first as white starts the game and is always a move ahead of black) -

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English oartihsin 2020-04-17 17:54:44 491 Initial revision (published)