# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875721 | Aiperiii | Easter Eggs (info1cup17_eastereggs) | C++14 | 1 ms | 460 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int findEgg (int N, vector < pair < int, int > > bridges)
{
vector <int> g[N+1];
for(int i=0;i<bridges.size();i++){
g[bridges[i].first].push_back(bridges[i].second);
g[bridges[i].second].push_back(bridges[i].first);
}
vector <int> vec,vis(N+1);
queue <int> q;
queue <vector <int> > d;
for(int i=1;i<=N;i++){
if(vis[i]==0){
q.push(i);
while(!q.empty()){
int v=q.front();
q.pop();
vec.push_back(v);
vis[v]=1;
for(auto to : g[v]){
if(vis[to]==0){
q.push(to);
break;
}
}
}
d.push(vec);
vec.clear();
}
}
while(!d.empty()){
vector <int> v=d.front();
d.pop();
if(query(v)==1){
if(v.size()==1){
cout<<v[0]<<endl;exit(0);
}
else{
int x=(v.size()+1)/2;
vector <int> s;
while(s.size()<x){
s.push_back(v.back());
v.pop_back();
}
d.push(v);
d.push(s);
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |