이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"highway.h"
#include<bits/stdc++.h>
#ifndef EVAL
#include"grader.cpp"
#endif
using namespace std;
vector<pair<int,int>>g[90005];
bool vis[90005];
int id[130005];
int under[130005];
int n,m;
long long pivot;
int depth(int root){
for(int i=0;i<n;i++)vis[i]=0;
queue<int>q;
int timer=0;
q.push(root);
vis[root]=1;
while(!q.empty()){
int v=q.front();
q.pop();
for(auto to:g[v])if(!vis[to.first]){
q.push(to.first);
vis[to.first]=1;
id[++timer]=to.second;
under[timer]=to.first;
}
}
int l=1,r=timer;
while(l<r){
int mid=(l+r+1)>>1;
vector<int>v(m,0);
for(int i=mid;i<=timer;i++)v[id[i]]=1;
if(ask(v)!=pivot)l=mid;
else r=mid-1;
}
return under[l];
}
void find_pair(int n,vector<int>x,vector<int>y,int a,int b){
::n=n;::m=x.size();
pivot=ask(vector<int>(m,0));
for(int i=0;i<m;i++){
g[x[i]].push_back({y[i],i});
g[y[i]].push_back({x[i],i});
}
answer(0,depth(0));
}
/*
5 4 1 2 0 4
0 1
0 2
1 3
1 4
*/
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |