#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
void dfs (int act, vector<vector<int>>& adj, vector<int>&li, int ant){
li.push_back(act);
for (int conex = 0; conex < (int)adj[act].size(); ++conex){
if (adj[act][conex] != ant) dfs(adj[act][conex], adj, li, act);
}
}
int findEgg (int N, vector<pair<int,int>>bridges){
vector<vector<int>> adj(N, vector<int>());
for (int i = 0; i < (int)bridges.size(); ++i){
adj[bridges[i].first - 1].push_back(bridges[i].second - 1);
adj[bridges[i].second - 1].push_back(bridges[i].first - 1);
}
vector<int>li, opt;
dfs (0, adj, li, 0);
int r = N-1, l = 0;
while (l < r){
int m = (l+r)/2;
opt.clear();
for (int i= 0; i <= m; ++i)opt.push_back(li[i]);
if (query(opt))r = m;
else l = m + 1;
}
return li[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
752 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |