hiho week 26 register

Ended

Participants:680

Verdict:Accepted
Score:100 / 100
Submitted:2014-12-27 22:47:04

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <map>
#define MAX_N 1000
#define INF 32767
using namespace std;
int N;
int cost[MAX_N][MAX_N];  // 
bool visited[MAX_N];  // X
int minCost[MAX_N];  // minCost[v] Xv
int prim() {
    int res = 0;
    for (int i = 0; i < N; i++) {
        visited[i] = false;
        minCost[i] = INF;
    }
    minCost[0] = 0;
    while (true) {
        int v = -1;
        for (int i = 0; i < N; i++) {
            if (!visited[i] && (v == -1 || minCost[i] < minCost[v])) {
                v = i;
            }
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX