제출 #673774

#제출 시각아이디문제언어결과실행 시간메모리
673774CookieTraffic (IOI10_traffic)C++14
0 / 100
1 ms1492 KiB
#include<bits/stdc++.h> using namespace std; #include "traffic.h" //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") #define ll long long #define vt vector #define pb push_back #define fi first #define se second #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) typedef unsigned long long ull; #include<fstream> ifstream fin("ss.inp"); ofstream fout("ss.out"); #define pii pair<int, int> #define pll pair<ll, ll> const ll mod = 1e9 + 7, mod2 = 1e9 + 9; const int mxn = 5e4, mxq = 1e5, sq = 800, mxm = 1e5; int n; vt<int>adj[mxn + 1]; ll sm[mxn + 1], a[mxn + 1], all = 0, s[mxn + 1], d[mxn + 1]; ll ans = 1e16, id = -1; void dfs(int s, int pre){ sm[s] = a[s]; ll mx = 0; for(auto i: adj[s]){ if(i != pre){ dfs(i, s); sm[s] += sm[i]; mx = max(mx, sm[i]); } } mx = max(mx, all - sm[s]); if(mx < ans){ ans = mx; id = s; } } int LocateCentre(int n, int a[], int s[], int d[]) { for(int i = 0; i < n; i++){ all += 1LL * a[i]; } forr(i, 0, n - 1){ adj[s[i]].pb(d[i]); adj[d[i]].pb(s[i]); } dfs(0, -1); return(id); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...