#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<vector<int>> g;
vector<int> ord;
void dfs(int v, int p){
ord.push_back(v);
for(auto &ch:g[v]) if(ch!=p) dfs(ch, v);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
g.assign(N, vector<int>()); ord.clear();
for(int i = 0; i < N-1; i++){
auto &[a, b]=bridges[i];
g[a-1].push_back(b-1);
g[b-1].push_back(a-1);
}
dfs(0, -1);
int l=1, r=N;
while(l<r){
int mid=(l+r)/2;
vector<int> tmp;
for(int i = 0; i < mid; i++) tmp.push_back(ord[i]+1);
if(!query(tmp)) l=mid+1;
else r=mid;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
444 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |