Блог пользователя hamidreza.hanify

Автор hamidreza.hanify, история, 6 лет назад, По-английски

Hello codeforces,

I'v recently been struggling with this problem Xor-MST.In it's tutorial it says u should use Boruvka's algorithm. For sake of learning i'v been trying to solve it using prim's algorithm but it runs out of time. I was wondering if it's some inefficiency in my coding or it's the algorithm which can't solve the problem in given time? here is my last code submitted: MY CODE

thanks in advance.

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

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

Your solution has complexity which is slow. Prim can be implemented in O(n2) time which still will be slow.

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

I think you can use Prim's algorithm with priority queue and trie structure to AC. The time complexity should be n.log(n) multiply a constant. Here is a code from my friend who used Prim's algorithm and trie structure :) CODE