Submission #426568

#TimeUsernameProblemLanguageResultExecution timeMemory
426568KalasLavasTraffic (IOI10_traffic)C++14
0 / 100
16 ms23784 KiB
#include <bits/stdc++.h> #include "traffic.h" using namespace std; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); //#undef LOCALKL #define IO \ ios_base::sync_with_stdio(0);(cin).tie(0);(cout).tie(0) #define y1 y1_ #define prev prev_ #define all(a) (a).begin(),(a).end() #define pb push_back #define eb emplace_back #define F first #define S second #ifdef LOCALKL // #define cerr cerr<<"\33[1;32m" // #define cout cout<<"\33[0m" #else #ifndef OO #define endl '\n' #define cerr if(1){}else cerr #endif #endif #define OK cout<<"OK\n"<<endl; #define setpre(k) fixed<<setprecision(k) #define mmset(k,y) memset(k,y,sizeof(k)) #define sz(x) ((int)(x).size()) using pii = pair<int,int>; using pll = pair<long long,long long>; using ull = unsigned long long; using intt = long long; using ll = long long; using ld = long double; const ll m9 = 998244353; const ll m7 = 1000000007; const ll m18 = 1000000000000000000; const ll i127 = 2139062143; const ll l127 = 9187201950435737471; vector<int>g[1000001]; int *a; ll res; pll ans = {INT_MAX, 0}; ll dfs(int v, int parent) { ll sum=0; for(int u : g[v]) if(u!=parent) sum+=dfs(u, v); res+=sum; return sum+a[v]; } int LocateCentre(int n, int pp[], int S[], int D[]) { a=pp; for(int i=0;i<n-1;i++) { g[S[i]].emplace_back(D[i]); g[D[i]].emplace_back(S[i]); } for(int i=0;i<n;i++) ans=min((res=0, dfs(i,-1), make_pair(res, (ll)i)), ans); return ans.S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...