Codeforces and Polygon may be unavailable from December 6, 19:00 (UTC) to December 6, 21:00 (UTC) due to technical maintenance. ×

Peace_789's blog

By Peace_789, history, 4 years ago, In English

Hey guys...

Recently I was solving this problem from CSES.

Here is what I have tried...

My idea

By implementing this idea , I am getting WA in one TC ( Out of 11 ).

You can find my code here.

code

So , can someone point out what am I doing wrong or any cases that I am missing.

Thanks in advance :)


UPD

As pwild sir pointed out , I was missing that cases.

To overcome that , I just added small logic to my code and it got ACCEPTED.

If you want to see code...

accepted code
  • Vote: I like it
  • +6
  • Vote: I do not like it

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

I did not check if this is what you actually do in your code, but erasing one edge in every cycle is not correct: a node that is not on the cycle can reach all nodes on the cycle, but for some of them this may require passing over the erased edge.

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

I recently stumbled upon this problem. Found this blog helpful. My code (Tried to code as simple as possible)

Here
  • »
    »
    2 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    One small doubt, why are we keeping a reverse graph, I cant understand the intuition behind that