What is wrong with my Prim's algorithm implementation?

Revision en3, by KimJennie, 2022-06-26 01:05:04

Hello, Codeforces!

I have to find MST with this algorithm, but got WA. Can you please help me? I would really appreciate that.

My submission: https://pastebin.com/P4nGmhRM Problem: https://codeforces.com/gym/100088/attachments It's in russian, but the idea is:

There are n cities. The mayor of city wants to build a roads, so you were able to visit one city from any another. And there are given n (x; y) coordinates, and you have to find minimum spanning tree. Obviously, in graph i and j (1 <= i,j <= n) are vertices, and the weight of edge is (x[i]-x[j])^2 + (y[i]-y[j])^2.

Tags prim algorithm, mst


  Rev. Lang. By When Δ Comment
en3 English KimJennie 2022-06-26 01:05:04 15
en2 English KimJennie 2022-06-26 01:03:25 425
en1 English KimJennie 2022-06-25 22:38:14 201 Initial revision (published)