#include <bits/stdc++.h>
using namespace std;
int query(vector<int> islands);
vector<int> G[513];
int c = 0, tot = 512;
int u[513], elim[513];
void dfs(int t, int v, int par = -1){
if(c == tot) return;
if(u[v] == 0) c++, u[v] = t;
for(auto i : G[v]){
if(i == par || elim[i])
continue;
dfs(t, i, v);
}
}
int findEgg(int N, vector<pair<int, int>> bridges){
for(int i = N / 2, t = 1; i != 1; i /= 2, t++){
tot = i; dfs(t, 1);
vector<int> islands;
for(int j = 1; j <= N; j++){
if(u[j]) islands.push_back(j);
}
int r = query(islands);
if(i == 1){
if(!r){
for(int i = 1; i <= N; i++){
if(u[i] == t) return i;
}
}else{
for(int i = 1; i <= N; i++){
if(u[i] == 0) return i;
}
}
}
if(!r){
continue;
}else{
for(int i = 1; i <= N; i++){
if(u[i] == 0) elim[i] = true;
if(u[i] == t) u[i] = 0;
}
}
}
}
Compilation message
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
50 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |