#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int findEgg (int N, vector <pair<int,int>> bridges)
{
vector<vector<int>> edge(N+1);
for(auto [u,v]:bridges){
edge[u].push_back(v);
edge[v].push_back(u);
}
vector<int> path;
function<void(int,int)> dfs = [&](int u,int p){
path.push_back(u);
for(int v:edge[u]) if(v!=p) dfs(v,u);
};
dfs(1,0);
int l=0,r=N-1;
while(l<r){
int mid=(l+r)>>1;
if(query(vector<int>(path.begin(),path.begin()+mid+1))) r=mid;
else l=mid+1;
}
return path[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
980 KB |
Number of queries: 8 |
2 |
Correct |
9 ms |
980 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
984 KB |
Number of queries: 9 |
4 |
Correct |
12 ms |
736 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
14 ms |
1024 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
744 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
708 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
644 KB |
Number of queries: 9 |