# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
272164 | erray | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// author: erray
#include<bits/stdc++.h>
using namespace std;
int findEgg(int n, vector<pair<int, int>> edges) {
vector<vector<int>> g(n);
for (auto e : edges) {
g[e.first - 1].push_back(e.second - 1);
g[e.second - 1].push_back(e.first - 1);
}
vector<int> ask;
function<void(int, int)> dfs = [&](int v, int pr) {
ask.push_back(v);
for (auto u : g[v]) {
if (u == pr) continue;
dfs(u, v);
}
};
dfs(0, -1);
int s = 0, e = n - 1;
while (s != e) {
int mid = (s + e) >> 1;
vector<int> q;
for (int i = 0; i <= mid; ++i) q.push_back(ask[i] + 1);
if (query(q)) e = mid;
else s = mid + 1;
}
return ask[s];
}