HighHopes's blog

By HighHopes, history, 6 years ago, In English

Disclaimer: This problem is from a contest on Hackerearth(hiring for intern) held on 13th April.


I was unable to solve this problem, can anyone help how to solve it? Can it be solved greedily or we need to use some graph algo?

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
6 years ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

The answer doesn't exceed 2. When the answer is 0, grid is already disconnected. When the answer is 1... , I don't have so good solution, but I'm glad if you read this.

this
  • »
    »
    6 years ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    One more solution which i guess is correct:

    Spoiler
    • »
      »
      »
      6 years ago, hide # ^ |
       
      Vote: I like it +9 Vote: I do not like it
      Correct special case