Code jam "Board Meeting" problem, what's wrong with my solution

problem: Code Jam - Google’s Coding Competitions

my solution is getting RE.
my solution for N=1, gSmvtm - Online C++0x Compiler & Debugging Tool - Ideone.com
my technique is,

  1. i seek distance of king from (-1000000,-1000000) its d1
  2. i seek distance of king from (1000000,1000000) its d2
  3. so now king is either on (x1,y1)= (-1000000+d1, 1000000-d2) or on (x2,y2)= (1000000-d2, -1000000+d1)

sol for testing, khL4Ps - Online C++0x Compiler & Debugging Tool - Ideone.com
here suppose king position is (500,1000), its showing correct solution in my pc.