#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> G[600];
int renumbered[600];
int inverse_renumber[600];
void renumber_dfs(int node,int father,int &val){
renumbered[node] = val;
inverse_renumber[val] = node;
for(auto it:G[node]){
if(it != father){
renumber_dfs(it,node,++val);
}
}
}
bool ok(int le,int ri){
vector<int> nodes;
for(int i = le;i <= ri;i++){
nodes.push_back(inverse_renumber[i]);
}
return query(nodes);
}
bool done_before = 0;
int findEgg (int N, vector < pair < int, int > > bridges){
if(!done_before){
for(auto it:bridges){
G[it.first].push_back(it.second);
G[it.second].push_back(it.first);
}
int start = 1;
renumber_dfs(1,0,start);
done_before = 1;
}
int lo = 1,hi = N;
while(hi - lo > 0){
int mid = (lo + hi) / 2;
if(ok(lo,mid)){
hi = mid;
}
else{
lo = mid + 1;
}
}
return inverse_renumber[lo];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Number of queries: 4 |
2 |
Runtime error |
3 ms |
564 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
672 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
764 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |