# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1209923 | PlayVoltz | Easter Eggs (info1cup17_eastereggs) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
vector<int> ord;
vector<vector<int> > graph;
void dfs(int node, int p){
ord.pb(node);
for (auto num:graph[node])if (num!=par)dfs(num, node);
}
int findEgg (int n, vector<pii> edges){
graph.clear();
ord.clear();
graph.resize(n+1);
for (auto c:edges){
graph[c.fi].pb(c.se);
graph[c.se].pb(c.fi);
}
dfs(1, -1);
int low=0, high=n;
while (low+1<high){
int mid=(low+high)/2;
vector<int> temp;
for (int i=0; i<mid)temp.pb(ord[i]);
if (query(temp))high=mid;
else low=mid;
}
return ord[high-1];
}