Submission #380427

#TimeUsernameProblemLanguageResultExecution timeMemory
380427ruadhanTraffic (IOI10_traffic)C++14
Compilation error
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; return 0; }

Compilation message (stderr)

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