#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 514;
vector<vector<int>>comps;
vector<int>comp;
vector<int>adj[N];
bool visited[N];
void dfs(int node){
visited[node] = true;
comp.push_back(node);
for(auto i : adj[node]){
if(visited[i]) continue;
dfs(i);
}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(auto i : bridges){
adj[i.first].push_back(i.second);
adj[i.second].push_back(i.first);
}
for(int i = 1; i <= n; i++){
if(!visited[i]){
dfs(i);
comps.push_back(comp);
comp.clear();
}
}
vector<int>a;
for(auto i : comps){
if(query(i)) {
a = i;
break;
}
}
for(auto i : a){
if(query({i})) return i;
}
return N;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |