#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int>adj[600];
vector<int>tour, cur;
void dfs(int x, int p){
tour.push_back(x);
for(int y:adj[x]){
if(y==p) continue;
dfs(y, x);
}
}
bool ask(int x){
cur.clear();
for(int i=0;i<=x;i++){
cur.push_back(tour[i]);
}
return query(cur);
}
int findEgg (int N, vector<pair<int, int>> bridges){
for(int i=1;i<=N;i++){
adj[i].clear();
}
for(auto p: bridges){
int x=p.first, y=p.second;
adj[x].push_back(y);
adj[y].push_back(x);
}
tour.clear();
dfs(1, 0);
int L=0, R=N-1;
while(L<R){
int M=(L+R)/2;
if(ask(M)) R=M;
else L=M+1;
}
return tour[L];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
256 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
256 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
384 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Number of queries: 8 |
2 |
Correct |
13 ms |
384 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
416 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
384 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |
2 |
Correct |
16 ms |
384 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
384 KB |
Number of queries: 9 |
4 |
Correct |
22 ms |
384 KB |
Number of queries: 9 |