#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> adjlist[513], ord;
void dfs(int x = 1, int par = 0){
ord.push_back(x);
for(int nxt : adjlist[x])
if(nxt != par) dfs(nxt, x);
}
int findEgg(int N, vector<pair<int, int>> bridges){
for(int i = 1; i <= N; i ++)
adjlist[i].clear();
ord.clear();
for(pair<int, int> it : bridges){
adjlist[it.first].push_back(it.second);
adjlist[it.second].push_back(it.first);
}
dfs();
int l = 0, r = N-1;
while(l != r){
int m = (l + r + 1) >> 1;
if(query(vector<int>(ord.begin(), ord.begin()+m)))
r = m-1;
else l = m;
}
return ord[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
2 ms |
200 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
336 KB |
Number of queries: 8 |
2 |
Correct |
13 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
336 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
356 KB |
Number of queries: 9 |
2 |
Correct |
16 ms |
336 KB |
Number of queries: 9 |
3 |
Correct |
17 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
448 KB |
Number of queries: 9 |