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

#TimeUsernameProblemLanguageResultExecution timeMemory
426772Emin2004Traffic (IOI10_traffic)C++14
100 / 100
1500 ms153088 KiB
#include "traffic.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define pii pair <int, int> #define pb push_back #define F first #define S second #define ll long long #define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define M_PI 3.14159265358979323846 const int N = 1000005; const int mod = 1e9 + 7; vector<int> a[N]; int w[N], dis[N], al, ans = INT_MAX, res; void DFS(int node, int par){ dis[node] = w[node]; for(int i : a[node]){ if(i == par) continue; DFS(i, node); dis[node] += dis[i]; } } void get(int node, int par){ int cur = al - dis[node]; for(int i : a[node]){ if(i == par) continue; cur = max(cur, dis[i]); get(i, node); } if(cur < ans) { ans = cur; res = node; } } int LocateCentre(int n, int r[], int to[], int from[]) { for(int i = 0; i < n - 1; i++){ a[to[i]].pb(from[i]); a[from[i]].pb(to[i]); } for(int i = 0; i < n; i++){ dis[i] = -1; w[i] = r[i]; } DFS(0, 0); al = dis[0]; get(0, 0); 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...