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

Автор haleyk100198, история, 8 лет назад, По-английски

Link to problem: http://mirror.codeforces.com/problemset/problem/505/D

My submission: http://mirror.codeforces.com/contest/505/submission/18861557

My idea is to count the amount of sub-trees of the graph that doesn't contain a cycle, and the answer would be n-(amount of sub-trees without a cycle). However my code fails on the test case 6 and I have no idea how did the test case got me... Can anyone point out the flaw of my code or even my approach on solving this problem?

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

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

Here is test 16 that fails your program. Also, graph can't be called a tree if it has cycle.

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

    Thanks for the test case, now I see the flaw my logic, didn't thought through the whole merge algorithm. :D

    Also for pointing out the wrong tag, now it has been updated.