Блог пользователя Peace_789

Автор Peace_789, история, 4 года назад, По-английски

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
  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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

Here
  • »
    »
    7 недель назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

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