#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<vector<int> > graph;
vector<int> euler;
void dfs(int u, int p) {
euler.push_back(u);
for(int &v : graph[u]) {
if(v == p) continue;
dfs(v, u);
}
}
int findEgg(int n, vector<pair<int, int> > edges) {
graph.clear();
euler.clear();
graph.resize(n+1);
for(auto &x : edges) {
graph[x.first].push_back(x.second);
graph[x.second].push_back(x.first);
}
dfs(1, 0);
int l=0, r=euler.size()-1;
int ans = 0;
while(l <= r) {
int mid = (l + r) / 2;
vector<int> to_query(euler.begin(), euler.begin() + mid + 1);
if(l == r) {
ans = r;
break;
}
if(query(to_query)) {
ans = mid;
r = mid - 1;
} else l = mid + 1;
}
return euler[ans];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |