#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pii pair<int, int>
const int N = 513;
vector<int> G[N], pre;
int n;
void dfs(int v, int p) {
pre.push_back(v);
for (auto u : G[v]) {
if (u == p) continue;
dfs(u, v);
}
}
vector<int> genIsl(int m) {
vector<int> res;
for (int i=0; i<=m; ++i) res.push_back(pre[i]);
return res;
}
int findEgg(int sz, vector<pii> x) {
n=sz;
for (auto u : x) {
int a=u.first, b=u.second;
G[a].push_back(b);
G[b].push_back(a);
}
dfs(1, 1);
int l=0, r=n-1;
while (l < r) {
int m=(l+r)/2;
if (query(genIsl(m))) r=m;
else l=m+1;
}
for (int i=0; i<=n; ++i) G[i].clear();
pre.clear();
return pre[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
208 KB |
Number of queries: 8 |
2 |
Correct |
10 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
336 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
336 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
16 ms |
336 KB |
Number of queries: 9 |