Submission #614372

#TimeUsernameProblemLanguageResultExecution timeMemory
614372kbk0421Traffic (IOI10_traffic)C++17
0 / 100
15 ms23804 KiB
#include <iostream> #include <vector> #include <numeric> #define INF 1e9 using namespace std; vector<int> G[1000010]; int d[1000010]; bool visited[1000010]; int sum; int mn = INF; int ans; int dfs(int x, int *P) { visited[x] = 1; int &ret = d[x] = P[x]; int mx = 0; cout << x << '\n'; for(auto &p : G[x]){ if(visited[p]) continue; int s = dfs(p,P); ret += s; mx = max(s, mx); } mx = max(sum-ret, mx); cout << x << '\n'; if(mx<mn){ mn = mx; ans = x; } cout << x << ' ' << ret << '\n'; return ret; } int LocateCentre(int N, int P[], int S[], int D[]) { for(int i=0; i<N; i++){ G[S[i]].push_back(D[i]); G[D[i]].push_back(S[i]); } sum = accumulate(P,P+N,0); cout << sum << '\n'; dfs(0,P); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...