Submission #636341

#TimeUsernameProblemLanguageResultExecution timeMemory
636341as111Traffic (IOI10_traffic)C++14
0 / 100
21 ms47188 KiB
#include <traffic.h> #include <vector> #define MAXN 1000000 using namespace std; int p[MAXN]; // parent int pop[MAXN]; vector<int> vals[MAXN];// amt congestion for each path coming out vector<int> adj[MAXN]; int total = 0; // total people everywhere int ans[MAXN]; void dfs(int x, int y) {//y is back edge p[x] = y; ans[x] = pop[x]; for (int e : adj[x]) { if (e == y) continue; dfs(e, x); ans[x] += ans[e]; } } int LocateCentre(int N, int P[], int S[], int D[]) { for (int i = 0; i < N - 1; i++) { total += P[i]; pop[i] = P[i]; adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } total += P[N - 1]; pop[N-1] = P[N - 1]; dfs(0, -1); int mn = 2000000005; int ansi = 0; for (int i = 0; i < N; i++) { int mx = 0; for (int val : vals[i]) { mx = max(mx, p[i] == val ? ans[0] - ans[i] : ans[val]); } if (mx < mn) { mn = mx; ansi = i; } } return ansi; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...