TAXITURN why wrong answer

Problem code : TAXITURN
Problem : TAXITURN Problem - CodeChef
Language used : C++
My code: CodeChef: Practical coding for everyone
Some comments to my code that I missed:

  • I used the formula angle between two vectors a and b = cosinverse[(a vector. b vector)/ab].
  • 22.0/28 = pi/4 = 45 degrees.
    Please tell me why my code is wrong. I tried the sample input given in the problem with my g++ compiler and it worked fine.
    Also I appreciate any advice to improve my programming.

EDIT:
I seem to have not ensured that the coordinates I change to are different from the rest and I also had not given enough size for the array to store the coordinates. I corrected it but still I’m getting wrong answer.
So this is my UPDATED CODE : CodeChef: Practical coding for everyone
I’ve also made it more easy to read. I would be glad if you could go though my code and spot the error I made.

I wish I knew what input code chef was using, if I knew that I know that I can definitely find the error. The code works fine for the sample input given in the problem page.

Hint: You can do all the operations in int/long long data type, no need to use floats. Ideally, even if you are using floats, your solution should pass. See some solutions attached in the corresponding editorial.

1 Like