#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
using ll = long long;
vector<int> v[1010], l;
void dfs(int u, int p) {
l.push_back(u);
for(auto x : v[u]) if(x != p) dfs(x, u);
}
int findEgg(int N, vector<pair<int, int>> bridges) {
for(int i=1;i<=N;i++) v[i].clear();
for(auto [x, y] : bridges) v[x].push_back(y), v[y].push_back(x);
dfs(1, 0);
int L = 0, R = N-2;
while(L <= R) {
int M = (L+R)/2;
if(query(vector<int>(l.begin(), l.begin()+M+1))) R = M-1;
else L = M+1;
}
return l[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 |
324 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
400 KB |
Number of queries: 8 |
2 |
Correct |
10 ms |
448 KB |
Number of queries: 9 |
3 |
Correct |
14 ms |
440 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
456 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
584 KB |
Number of queries: 9 |
2 |
Correct |
13 ms |
456 KB |
Number of queries: 9 |
3 |
Correct |
16 ms |
508 KB |
Number of queries: 9 |
4 |
Correct |
15 ms |
456 KB |
Number of queries: 9 |