#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define MAX_N 513
vector <int> adj[MAX_N] ,active ,Set;
int SZ;
void dfs(int u ,int p=-1){
if(!SZ)
return;
Set.push_back(u);
if(find(active.begin() ,active.end() ,u) != active.end())
SZ--;
for(int&v : adj[u]) if(v != p)
dfs(v ,u);
}
vector <int> findSet(int sz){
SZ = sz;
Set.clear();
dfs(1);
return Set;
}
int findEgg (int N, vector < pair < int, int > > bridges){
for(auto&e : bridges)
adj[e.first].push_back(e.second),
adj[e.second].push_back(e.first);
active.resize(N);
iota(active.begin() ,active.end() ,1);
while(active.size() > 1){
vector <int> vs = findSet(((int)active.size())/2);
if(query(vs)){
vector <int> nv;
for(int&v : vs)
if(find(active.begin() ,active.end() ,v) != active.end())
nv.push_back(v);
active = nv;
}else{
for(int&v : vs)
if(find(active.begin() ,active.end() ,v) != active.end())
active.erase(find(active.begin() ,active.end() ,v));
}
}
return active.front();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
640 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 |
5 ms |
640 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 |
16 ms |
888 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |