Unfortunately we were unable to fully decode your file, as it is not encoded in UTF-8. You can try to decode it yourself by downloading it here.
 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//Kuglarz [A], PA 2014, 1 runda
//Wiktoria Ko�ny
#include<cstdio>
#include<queue>
using namespace std;

const int MN=2005;
long long MX=(long long)1000000005, wyn=0, koszt[MN];
int n, sas[MN][MN], odw[MN], iodw=1;
priority_queue< pair<long long, int> > kol;

void wrzuc(int v, long long c){
	//printf("wrzucam %d %lld\n", v, c);
	int i;
	odw[v]=1;
	koszt[v]=c;
	wyn+=c;
	for(i=1; i<=n; i++){
		if(i!=v && odw[i]==0 && sas[v][i]<koszt[i]){
			koszt[i]=sas[v][i];
			kol.push(make_pair(-koszt[i], i));
		}
	}	
}

int main(){
	int i, j, a, v, c;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		sas[i][i]=MX;
		for(j=i+1; j<=n+1; j++){
			scanf("%d", &a);
			sas[i][j]=a;
			sas[j][i]=a;
		}
	}
	n++;
	sas[n][n]=MX;
	for(i=0; i<=n; i++){
		odw[i]=0;
		koszt[i]=MX;
	}
	
	/*for(i=1; i<=n; i++){
		for(j=1; j<=n; j++)
			printf("%d ", sas[i][j]);
		printf("\n");
	}*/
	
	wrzuc(1, 0);
	while(iodw<n){
		while(odw[kol.top().second])
			kol.pop();
		v=kol.top().second;
		c=-kol.top().first;
		kol.pop();
		wrzuc(v, c);	
		iodw++;
	}
	

	printf("%lld\n", wyn);
	return 0;
}