#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int maxn = 600;
vector<int> edges[maxn];
int st[maxn], ed[maxn], vert[maxn], timer = 0;
void dfs(int x, int p){
st[x] = ++timer;
vert[timer] = x;
for(auto i : edges[x]){
if(i != p){
dfs(i, x);
}
}
ed[x] = timer;
}
int ask(int x){
vector<int> v;
for(int i = 1; i <= x; ++i){
v.push_back(vert[i]);
}
int ret = query(v);
return ret;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
for(int i = 1; i <= N; ++i){
edges[i].clear();
st[i] = vert[i] = 0;
}
timer = 0;
for(auto i : bridges){
edges[i.first].push_back(i.second);
edges[i.second].push_back(i.first);
}
dfs(1, 1);
int lo = 1, hi = N, ans = -1;
while(lo <= hi){
int mid = (lo + hi) >> 1;
if(ask(mid)){
ans = mid;
hi = mid - 1;
}else {
lo = mid + 1;
}
}
return st[ans];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
620 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
620 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |