This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("unroll-loops, O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
int n, a[1000000], cnt[1000000], mx[1000000];
vector<int> adj[1000000];
void dfs(int vtx, int pre, vector<vector<int>> &adj, vector<int> &cnt, vector<int> &mx, int a[]){
mx[vtx] = 0, cnt[vtx] = a[vtx];
for(int i : adj[vtx])
if(i != pre){
dfs(i, vtx, adj, cnt, mx, a);
cnt[vtx] += cnt[i];
mx[vtx] = max(mx[vtx], cnt[i]);
}
}
int LocateCentre(int n, int a[], int s[], int d[]){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector<vector<int>> adj(n);
vector<int> cnt(n), mx(n);
for(int i = 0; i < n - 1; i++){
adj[s[i]].push_back(d[i]);
adj[d[i]].push_back(s[i]);
}
dfs(0, -1, adj, cnt, mx, a);
pair<int, int> ans(INT_MAX, -1);
for(int i = 0; i < n; i++)
ans = min(ans, make_pair(max(cnt[0] - cnt[i], mx[i]), i));
return ans.second;
}
Compilation message (stderr)
traffic.cpp:1:40: warning: bad option '-f O3' to pragma 'optimize' [-Wpragmas]
1 | #pragma GCC optimize("unroll-loops, O3")
| ^
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
2 | #pragma GCC target("avx")
| ^
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
traffic.cpp:2:25: warning: bad option '-f O3' to attribute 'optimize' [-Wattributes]
/var
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |