#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int MAXN = 513;
vector<int> adjlist[MAXN], v, vis(MAXN);
void dfs(int x=1){
vis[x] = 1; v.push_back(x);
for(int nxt : adjlist[x])
if(!vis[nxt]) dfs(nxt);
}
int findEgg(int N, vector<pair<int, int>> bridges){
for(int i = 0; i < N; i ++)
adjlist[i].clear();
fill(vis.begin(), vis.end(), 0);
v.clear();
for(pair<int, int> it : bridges){
adjlist[it.first].push_back(it.second);
adjlist[it.second].push_back(it.first);
}
dfs();
int l = 0, r = N-1, ans = -1;
while(l <= r){
int m = (l + r) >> 1;
if(query(vector<int>(v.begin(), v.begin()+m))){
r = m-1; ans = m;
} else l = m+1;
}
return v[ans];
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
484 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |