By AJAYHAYAGREEVE, history, 3 years ago, In English

Hi guys, Am trying to solve the problem 492 D. http://codeforces.com/problemset/problem/492/D. My approach is use binary search, to find the index at which the monster dies. My solution is https://ide.geeksforgeeks.org/Dcs5Fn6w2S. But i got wrong answer in test 7. so i changed the equal function to compare upto 10^-6. Then i got wrong answer on test 6. Can someone plz tell me why this method fails.

  • Vote: I like it
  • 0
  • Vote: I do not like it

3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I think it's about precision error. I've tried using binary search but got WA many times with various epsilon value (1e-9 ~ 1e-15). You could try to change your approach to only consider the last second before the monster dead by bruteforcing the turn of X and Y (in span of 1 second).