When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

pandey_04's blog

By pandey_04, 3 years ago, In English

Link to problem: problem Link to editorial: editorial

Problem B — Bad boy

I got the idea given in editorial but can anyone tell me how the distance will always be 2*(n — 1) + 2*(m — 1) when putting the two yoyos in corners which form a diagonal. And, won't the distance be larger if we put the yoyos on the diagonal which is farther from the position of Riley than the one which is closer ?? How the largest distance is always same irrespective of position of Riley. All comments are highly appreciated.

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

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

The important thing here is that Riley's (or Anton's) position does not matter.
The distance can be maximized if Riley needs to travel along both the length and the width of the room twice.

This can be easily accomplished by placing the yoyos in 2 opposite corners ((1,1 and n, m) or (1,m and n,1)).

If both the yoyos are placed in such a manner, no matter where Riley is, he will always need to travel the maximum distance; because if he ends up closer to one of the yoyos, the distance between him and the second yoyo will become greater, and vice-versa...