제출 #380432

#제출 시각아이디문제언어결과실행 시간메모리
380432ruadhanTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const ll INF = 2e12 + 2; const int MAXN = 1e6 + 1; ll congestion = 0; vector<int> adj[MAXN]; vector<int> population; vector<bool> visited; void dfs(int node) { for (auto u : adj[node]) { if (!visited[u]) { congestion += population[u]; visited[u] = true; dfs(u); } } } int LocateCentre(int N, vector<int> P, vector<int> S, vector<int> D) { ll ans = INF; population = P; for (int i = 0; i < N - 1; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } for (int i = 0; i < N; i++) // try city i { visited.assign(N, false); visited[i] = true; ll currentWorst = 0; for (auto u : adj[i]) // all outgoing edges have different congestion { congestion = P[u]; visited[u] = true; dfs(u); currentWorst = max(currentWorst, congestion); } ans = min(ans, currentWorst); } return ans; } int main() { // int n = 5; // vector<int> p = {10, 10, 10, 20, 20}; // vector<int> s = {0, 1, 2, 3}; // edges // vector<int> d = {2, 2, 3, 4}; // cout << LocateCentre(n, p, s, d) << endl; ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> p(n), s(n - 1), d(n - 1); for (auto &x : p) cin >> x; for (int i = 0; i < n - 1; i++) cin >> s[i] >> d[i]; cout << LocateCentre(n, p, s, d) << endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

/tmp/ccZp9rrL.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccPywnJ0.o:traffic.cpp:(.text.startup+0x0): first defined here
/tmp/ccZp9rrL.o: In function `main':
grader.cpp:(.text.startup+0xd9): undefined reference to `LocateCentre(int, int*, int*, int*)'
collect2: error: ld returned 1 exit status