# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
918918 | Moonn | Easter Eggs (info1cup17_eastereggs) | C++17 | 2 ms | 812 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>
#define inti long long
#define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
vector<vector<int>>v;
vector<bool>ch;
vector<int>g;
int query(vector<int> islands);
void dfs(int n,int x)
{
ch[x]=1;
for(int i:v[x])
{
if(!ch[i])
dfs(n,i);
}
g.push_back(x);
}
int findEgg(int n, vector < pair < int, int > > bridges)
{
v.resize(n+1);
ch.resize(n+1,0);
for(int i=0;i<bridges.size();i++)
{
int a=bridges[i].first;
int b=bridges[i].second;
v[a].push_back(b);
v[b].push_back(a);
}
dfs(n,1);
int l,r,mid;
l=0;
r=g.size()-1;
vector<int>vi;
while(l<r)
{
vi.clear();
mid=(l+r)/2;
for(int i=0;i<=mid;i++)
vi.push_back(g[i]);
if(query(vi))
r=mid;
else
l=mid+1;
}
return g[r];
}
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... |