Блог пользователя newbie_forever_at_cp

Автор newbie_forever_at_cp, история, 7 лет назад, По-английски

Hi guys, Am trying to solve the problem 492 D. http://codeforces.net/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.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
7 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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).