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

Автор angelg, 11 лет назад, По-английски

Hello, I have been trying to solve a problem from a Gym Contest (http://mirror.codeforces.com/gym/100484/attachments — 100484G — Highways). It seems like an straightfoward Kruskal implementation to me. At first, I was using a vector to store all the edges, but that resulted in MLE in testcase 21. Only then I came to realize N could be upto 10^4, and there's no way to store 10^4 * 10^4 edges without getting a MLE veredict.

Is there an heuristic or data structure to quickly calculate the minimum distance between all the points and generate the MST of the given graph?

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

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

why you want to store 10^4 * 10^4 edges the maximum number of edges you need to store is 10^4 edge

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

you do not need to store it , just calculate it every time . Also kruskal will not work in this problem cause u cannot sort 10^8 edges . so use prim with arraylist implementation