#include <bits/stdc++.h>
#include "grader.h"
#define f first
#define s second
using namespace std;
int n;
vector<int> preord;
vector<int> grph[690];
void dfs(int x, int lst=-1) {
preord.push_back(x);
for (int i : grph[x]) if (i!=lst) {
dfs(i,x);
}
}
bool test(int x) {
vector<int> t;
for (int i=0; i<x; i++) {
t.push_back(preord[i]+1);
}
return query(t);
}
int findEgg (int N, vector<pair<int,int>> bridges) {
preord.clear();
for (int i=0; i<690; i++) {
grph[i].clear();
}
n=N;
for (auto i:bridges) {
i.f--;i.s--;
grph[i.f].push_back(i.s);
grph[i.s].push_back(i.f);
}
dfs(0);
int s=0,e=n;
while(s+1!=e) {
int m=(s+e)/2;
(test(m)?e:s)=m;
}
return preord[s]+1;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
6 ms |
348 KB |
Number of queries: 8 |
2 |
Correct |
14 ms |
340 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
19 ms |
348 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
376 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
352 KB |
Number of queries: 9 |
3 |
Correct |
17 ms |
336 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
356 KB |
Number of queries: 9 |