# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1111943 | epicci23 | Highway Tolls (IOI18_highway) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#include "highway.h"
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
const int N = 1e5 + 5;
vector<int> v[N],Xor,depth[N],Res;
int n,m,A,B,Dist,vis[N],par[N],sub[N];
inline int oth(int c,int u) {return Xor[c] ^ u;}
void upd(int c,int d){
sub[c]=1;
depth[d].push_back(c);
for(int ind:v[c]){
int x = oth(ind,c);
if(ind==par[c] || vis[x]) continue;
par[x]=ind;
upd(x,d+1);
sub[c]+=sub[x];
}
}
int we_know_root(int rt){
for(int i=0;i<N;i++) depth[i].clear();
par[rt]=-1;
upd(rt,rt,0);
int l = 0 , r = sz(depth[Dist]) - 1;