// author: erray
#include<bits/stdc++.h>
#include"grader.h"
using namespace std;
//int query(vector<int> asd) { return true; }
const int N = 515;
vector<int> g[N], ask;
void dfs(int v, int pr = -1) {
ask.push_back(v);
for (auto u : g[v]) {
if (pr == u) continue;
dfs(u, v);
}
}
int findEgg(int n, vector<pair<int, int>> edges) {
bool ok = true;
for (int i = 0; i < 512; ++i) ok &= g[i].empty();
for (auto e : edges) {
if (ok) {
g[e.first].push_back(e.second);
g[e.second].push_back(e.first);
}
}
dfs(1);
int s = 0, e = n - 1;
while (s != e) {
int mid = (s + e) >> 1;
if (query(vector<int>(ask.begin(), ask.begin() + mid + 1))) e = mid;
else s = mid + 1;
}
return ask[s];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
384 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
388 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
384 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
412 KB |
Number of queries: 8 |
2 |
Correct |
12 ms |
512 KB |
Number of queries: 9 |
3 |
Correct |
18 ms |
632 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
632 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
636 KB |
Number of queries: 9 |
2 |
Correct |
15 ms |
632 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
760 KB |
Number of queries: 9 |
4 |
Correct |
24 ms |
640 KB |
Number of queries: 9 |