#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> order;
void dfs(int v, int prev, vector<int> &order, vector<vector<int>> &g)
{
order.push_back(v);
for(int i : g[v])
{
if(i == prev)continue;
dfs(i, v, order, g);
}
}
int query(vector < int > islands);
int findEgg(int n, vector<pair<int, int>> bridges)
{
g.resize(n+1);
for(auto &[u, v] : bridges)
{
g[u].push_back(v);
g[v].push_back(u);
}
dfs(1, 0, order, g);
int l = 0, r = n-1;
while(l <= r)
{
int mid = (l + r) >> 1;
if(query(vector<int> (order.begin(), order.begin() + mid)))
r = mid;
else
l = mid + 1;
}
return order[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
432 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 |
3 ms |
496 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |