LIFE_GOES_ON's blog

By LIFE_GOES_ON, history, 5 years ago, In English

Here in this 1073C - Vasya and Robot my observations are -

1)If (abs(x) + abs(y)) < string_length then ans -1

2)If (abs(x) + abs(y)) > string_length and ((abs(x) + abs(y))-string_length)%2 != 0 then also ans -1

Then I was thinking like, okay only way can be binary approach or any tiring greedy approach. But none of these could not help to proceed. Because If I will use binary search, how can I increase or decrease the length.

Do not put any direct solution. Just hints or just let me know where my thinking is wrong?

  • Vote: I like it
  • +8
  • Vote: I do not like it

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

I am trying to be very subtle...

Spoiler
  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    On length. But,if on length, from where it has to be started?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it
      Spoiler
      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Nice. I have got it. But I thought, checking for each length might cause TLE. Because for each length there would be (n-len) positions to check.

        But it won't. Because we might have to check for logn length. And in worst case there might be nlogn complexity . Well I do not know if my calculation of TL is right :3 But I have got the idea. Can you please explain the complexity? And thanks for being subtle <3

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it
          Spoiler