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

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

I just solved the V-Subtree problem on AtCoder DP Contest, and after solving it, I couldn't find anyone who solved it iteratively, so I decided to share my code with you :)

My code (without my template)

My idea was that, to do a topological sort iteratively, I thought I had to use Kahn's algorithm. When I found that I was getting a wrong answer, I tried to find the problem, and it turned out that the tree was undirected. After some deep thinking, I realized that I could treat the tree as directed, so I sorted the elements by their distance from the root (any root can be taken since it's undirected). Then, I went on to write the answer code :)

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

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

Auto comment: topic has been updated by darkahmed (previous revision, new revision, compare).

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

Auto comment: topic has been updated by darkahmed (previous revision, new revision, compare).

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

Gamed

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

Great

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

Amazing!