제출 #348501

#제출 시각아이디문제언어결과실행 시간메모리
348501juggernaut통행료 (IOI18_highway)C++14
0 / 100
18 ms6124 KiB
#include"highway.h" #include<bits/stdc++.h> #ifndef EVAL #include"grader.cpp" #endif using namespace std; vector<pair<int,int>>g[90005]; vector<int>grp[90005]; int id[90005],mx,up[90005]; long long pivot; void dfs(int v,int p,int depth){ mx=max(mx,depth); grp[depth].push_back(id[v]); for(auto to:g[v])if(to.first!=p){ id[to.first]=to.second; up[to.second]=to.first; dfs(to.first,v,depth+1); } } void find_pair(int n,vector<int>x,vector<int>y,int a,int b){ for(int i=0;i<n-1;i++){ g[x[i]].push_back({y[i],i}); g[y[i]].push_back({x[i],i}); } vector<int>v(n-1,0); pivot=ask(v); dfs(0,0,0); int l=1,r=mx; while(l<r){ //cout<<l<<"_"<<r<<endl; int mid=(l+r)>>1; vector<int>(n-1,0); for(int i=mid+1;i<=mx;i++)for(auto to:grp[i])v[to]=1; //cout<<"QUERY:"; //for(auto to:v)cout<<to; //cout<<" "<<ask(v)<<endl; if(ask(v)!=pivot)l=mid+1; else r=mid; } int uid=l; //cout<<uid<<endl; l=0,r=grp[uid].size()-1; while(l<r){ int mid=(l+r)>>1; vector<int>v(n-1,0); for(int i=l;i<=mid;i++)v[grp[uid][i]]=1; if(ask(v)!=pivot)r=mid; else l=mid+1; } int s=up[grp[uid][l]]; answer(0,s); } /* 5 4 1 2 0 4 0 1 0 2 1 3 1 4 */
#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...