#include <bits/stdc++.h>
using namespace std;
int query(vector < int > islands);
void dfs(int v, int p, vector<vector<int>>& adj, vector<int>& ans){
ans.push_back(v);
for(int u:adj[v]){
if(u==p)continue;
dfs(u, v, adj, ans);
}
}
int findEgg(int N, vector < pair < int, int > > bridges){
vector<int> ans;
vector<vector<int>> adj(N+1, vector<int>());
for(auto x:bridges){
adj[x.first].push_back(x.second);
adj[x.second].push_back(x.first);
}
dfs(1, 0, adj, ans);
int l=0,r=N-1;
while(r!=l){
int m=(r+l+1)/2;
vector<int> q;
for(int i=0;i<=m;++i)q.push_back(ans[i]);
if(query(q))r=m-1;
else l=m;
}
return ans[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |