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

Автор mercyme, история, 16 месяцев назад, По-английски

I am trying to solve the problem J: Computer Networks here: https://mirror.codeforces.com/gym/100114 Basically we have to add one more edge to the graph so that the total number of bridges is minimized. (And the given graph may have multiple edges between two vertices).

What I am doing is that first I find all the bridges (using the technique given here: https://mirror.codeforces.com/blog/entry/68138) and while doing so, I also divide the graph into biconnected components and make a tree out of those components. Like so:

Then I just find the longest distance between any two nodes in that tree by first finding the longest distance from a root to a node and then from that node to another node.

I really feel this is correct and my implementation is wrong: https://pastebin.com/NESHhvGm

The problem is that the test cases are not visible either and every code outputs something different. It is difficult to check where I went wrong.

If someone can give me an AC code or any sort of help would be great.

  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

»
16 месяцев назад, # |
Rev. 2   Проголосовать: нравится +11 Проголосовать: не нравится

Notice that the problem wants you to input from a file and output to a file (input.txt / output.txt):

You are reading from standard input and writing to standard output.