(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 #362400

#TimeUsernameProblemLanguageResultExecution timeMemory
362400wind_reaperTraffic (IOI10_traffic)C++17
100 / 100
1180 ms170892 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<int64_t> cur, child, mx; int64_t fans = 0; void dfs(int node, int par){ for(int v : adj[node]){ if(v == par) continue; dfs(v, node); mx[node] = max(mx[node], child[v]); child[node] += child[v]; } mx[node] = max(mx[node], fans - child[node] - cur[node]); child[node] += cur[node]; } int LocateCentre(int n, int p[], int s[], int d[]){ adj.resize(n); cur.resize(n); child.resize(n); mx.resize(n); 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++){ cur[i] = p[i]; fans += p[i]; } dfs(0, 0); return min_element(mx.begin(), mx.end()) - mx.begin(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...