(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #307307

#TimeUsernameProblemLanguageResultExecution timeMemory
307307zoemberTraffic (IOI10_traffic)C++11
100 / 100
1279 ms168440 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN = 1e6, MAXN2 = 2e9+1; int total = 0, ans = MAXN2; vector<int> adj[MAXN], biggest(MAXN, 0), children(MAXN, 0); void dfs(int vertex, int parent, int p[]) { for(int next: adj[vertex]) { if(next != parent) { dfs(next, vertex, p); children[vertex] += children[next]; biggest[vertex] = max(children[next], biggest[vertex]); } } biggest[vertex] = max(biggest[vertex], total-p[vertex]-children[vertex]); children[vertex] += p[vertex]; } int LocateCentre(int n, int p[], int s[], int d[]) { 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++) { total += p[i]; } dfs(0, -1, p); int res = 0; for(int i=0; i<n; i++) { if(biggest[i] < ans) { res = i; ans = biggest[i]; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...