Submission #414874

#TimeUsernameProblemLanguageResultExecution timeMemory
414874JediMaster11Traffic (IOI10_traffic)C++17
50 / 100
5036 ms27328 KiB
#include <bits/stdc++.h> #include "traffic.h" using namespace std; #define ll long long #define uint unsigned int #define ull unsigned long long #define endl "\n" #define elif else if #define fo(i, a, b) for (int i = a; i < (int)b; i++) #define rfo(i, a, b) for (int i = a - 1; i >= b; i--) #define v(i) vector<i> #define vll vector<long long> #define vstr vector<string> #define pairll pair<long long, long long> #define vpairll vector<pair<long long, long long>> #define print(x) cout << x << "\n" #define pushall(x, n) \ x.resize(n); \ for (int zz = 0; zz < (int)n; zz++) \ { \ cin >> x[zz]; \ } const int MAX_N = 1e6 + 3e2; vector<int> adj[MAX_N]; int dfss(int u, int p, int P[]) { int ans = P[u]; for(int to : adj[u]) { if(to == p) continue; ans += dfss(to, u, P); } return ans; } int LocateCentre(int Nn, int Ps[], int S[], int D[]) { int N = Nn; for(int i = 0; i < N-1; i++) { adj[S[i]].push_back(D[i]); adj[D[i]].push_back(S[i]); } int ans = 2147483647, ret = -1; for(int i = 0; i < N; i++) { int max_traffic = -2147483648; for(int to : adj[i]) { max_traffic = max(max_traffic, dfss(to, i, Ps)); } if(max_traffic < ans) { ans = max_traffic; ret = i; } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...