이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
#define N 100005
using namespace std;
vector<pair<int,int>> adj[N];
int par[N];
int paredge[N];
vector<int> x;
void dfs(int v,int pr,int predge,int dep){
par[v] = pr;
paredge[v] = predge;
if(dep == 0){
x.push_back(v);
return;
}
for(auto u:adj[v]){
if(u.first == pr)continue;
dfs(u.first,v,u.second,dep-1);
}
}
void find_pair(int n, vector<int> u, vector<int> v, int a, int b) {
int m = u.size();
for(int i = 0;i<m;i++){
adj[u[i]].push_back({v[i],i});
adj[v[i]].push_back({u[i],i});
}
vector<int> w(m,0);
int dep = ask(w) / a;
dfs(0,-1,-1,dep);
while(x.size() > 1){
vector<int> tmp;
while(tmp.size() < x.size()){
tmp.push_back(x.back());
x.pop_back();
}
w.assign(m,0);
for(auto u:tmp){
w[paredge[u]] = 1;
}
if(ask(w) != dep * a){
x = tmp;
}
}
answer(0, x[0]);
}
# | 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... |