Submission #676212

#TimeUsernameProblemLanguageResultExecution timeMemory
676212lebasivillarTraffic (IOI10_traffic)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e6 + 5;

int n;
int p[MAXN];
int s[MAXN], d[MAXN];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> s[i] >> d[i];
	}

	int minCongestion = INT_MAX;
	int minCongestionCity;
	for (int i = 0; i < n; i++) {
		int congestion = 0;
		for (int j = 0; j < n - 1; j++) {
			if (s[j] == i || d[j] == i) {
				congestion += p[s[j]] + p[d[j]];
			}
		}
		if (congestion < minCongestion) {
			minCongestion = congestion;
			minCongestionCity = i;
		}
	}

	cout << minCongestionCity << endl;
	return 0;
}

Compilation message (stderr)

traffic.cpp: In function 'int main()':
traffic.cpp:34:10: warning: 'minCongestionCity' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |  cout << minCongestionCity << endl;
      |          ^~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccp4tf7g.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJoXq4f.o:traffic.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccp4tf7g.o: in function `main':
grader.cpp:(.text.startup+0xe1): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status