M.A.H.M.O.O.D's blog

By M.A.H.M.O.O.D, history, 7 years ago, In English

Hi everyone.

I'm trying to solve this 687A - NP-Hard Problem but I'm getting WA on test 15 and the input is too large for me to process where I'm going wrong, So I was hoping that someone that has solved it would take a look at my code and tell me where I'm going wrong ???

Thank you for reading.

My submission 21828109

:)

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

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

you were considering only one disjoint set of vertices in your solution while the problem states that each edge uv there is at least one endpoint of it in the set so u cannot neglect others except the ones which have consist only one vertex because it is edgeless so u can give it to anyone.

here is the link of your accepted solution after modification. http://codeforces.com/contest/687/submission/21830565

by the way why are you using mod_DFS in your code ?

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

    It's nothing I thought that my DFS function wasn't marking all node as visited because of some programming mistake so I made it to make sure that all node are marked but that wasn't the case and I forgot to delete it.

    It turns out the error was my understanding of the problem.

    Anyway thank you very much for your effort.

    :)

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

    Did not understand it properly. Could you please explain in detail? I am also stuck with the same problem. http://codeforces.com/contest/687/submission/33897972