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