Pankaj_Panwadi's blog

By Pankaj_Panwadi, history, 4 years ago, In English
  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

You are storing visited co-ordinates in the set. You should store the segments instead. Run your code for this TestCase

TestCase

Correct ans is 20,while your code gives 16.

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

    Can you elaborate a little further? I think I am not able to understand the question

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

      Move (a, b) -> (c, d) costs 1 if and only if you've made (a, b) <-> (c, d) move before and 5 otherwise

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

You dont need to store the positions. You need the paths. Do it using a pair of pairs <x,y> to <a,b>