#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> g[600];
vector<int> w;
void dfs(int at, int p) {
w.push_back(at);
for (int to: g[at]) {
if (to == p) continue;
dfs(to, at);
}
}
int findEgg (int n, vector < pair < int, int > > edges) {
for (int i=0; i<=n; i++) {
g[i].clear();
}
for (auto ed: edges) {
int u = ed.first;
int v = ed.second;
g[u].push_back(v);
g[v].push_back(u);
}
w.clear();
dfs(1,0);
assert((int)w.size()==n);
int lo = 0;
int hi = n;
while (hi-lo>1) {
int mid = (lo+hi)/2;
vector<int> v;
for (int i=0; i<=mid; i++) v.push_back(w[i]);
if (query(v)) {
lo = mid;
} else {
hi = mid;
}
}
return -1;
return w[lo];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
572 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |