제출 #1111946

#제출 시각아이디문제언어결과실행 시간메모리
1111946epicci23통행료 (IOI18_highway)C++17
12 / 100
113 ms72008 KiB
#include "bits/stdc++.h" #include "highway.h" #define ll long long #define all(v) v.begin() , v.end() #define sz(a) (ll)a.size() using namespace std; const ll N = 2e5 + 5; vector<ll> v[N],Xor,depth[N]; vector<int> Res; ll n,m,A,B,Dist,vis[N],par[N],sub[N]; inline ll oth(ll c,ll u) {return Xor[c] ^ u;} void upd(ll c,ll d){ sub[c]=1; depth[d].push_back(c); for(ll ind:v[c]){ ll x = oth(ind,c); if(ind==par[c] || vis[x]) continue; par[x]=ind; upd(x,d+1); sub[c]+=sub[x]; } } ll we_know_root(ll rt){ for(ll i=0;i<N;i++) depth[i].clear(); par[rt]=-1; upd(rt,0); ll l = 0 , r = sz(depth[Dist]) - 1; while(l<r){ ll mid = (l+r)/2; Res.assign(m,0); for(ll i=0;i<=mid;i++){ ll cur = depth[Dist][i]; while(cur != rt){ Res[par[cur]]=1; cur = oth(par[cur], cur); } } if(ask(Res)==Dist*B) r=mid; else l=mid+1; } return depth[Dist][l]; } void find_pair(int _n, vector<int> U, vector<int> V, int _A, int _B){ A=_A,B=_B; m = sz(U),n = _n; for(ll i=0;i<m;i++){ Xor.push_back(U[i]^V[i]); v[U[i]].push_back(i); v[V[i]].push_back(i); } Res.assign(m,0); Dist = ask(Res) / A; answer(0, (int) we_know_root(0)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...