#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define mk 513
vector <int> g[mk] ,cur_node, Set;
int SZ;
void dfs(int u ,int p=-1){
if(!SZ)
return;
Set.push_back(u);
if(find(cur_node.begin() ,cur_node.end() ,u) != cur_node.end())
SZ--;
for(int v : g[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){
cur_node.clear();
for(int i=0; i<=N; i++)
g[i].clear();
for(auto&e : bridges)
g[e.first].push_back(e.second),
g[e.second].push_back(e.first);
cur_node.resize(N);
iota(cur_node.begin() ,cur_node.end() ,1);
while(cur_node.size() > 1){
vector <int> vs = findSet(((int)cur_node.size())/2);
if(2 == 3){
vector <int> nv;
for(int&v : vs)
if(find(cur_node.begin(), cur_node.end() ,v) !=cur_node.end())
nv.push_back(v);
cur_node = nv;
}else{
for(int&v : vs)
if(find(cur_node.begin() ,cur_node.end() ,v) != cur_node.end())
cur_node.erase(find(cur_node.begin() ,cur_node.end() ,v));
}
}
return cur_node.front();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
384 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
384 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |