# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082582 | KALARRY | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 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.
//chockolateman
#include<bits/stdc++.h>
using namespace std;
int n,total = 512,counter;
bool asked[520];
vector<int> adj[520];
vector<int> to_ask;
bool possible[520];
void init(int N)
{
n = N;
for(int i = 1 ; i <= n ; i++)
adj[i].clear();
total = 0;
for(int i = 1 ; i <= n ; i++)
{
asked[i] = false;
possible[i] = true;
total++;
}
}
void dfs(int v,int p)
{
counter += possible[v];
to_ask.push_back(v);
asked[v] = true;
for(auto u : adj[v])
{
if(counter==total/2)
return;
if(u!=p)
dfs(u,v);
}
}
int findEgg(int N, vector < pair < int, int > > bridges)
{
init(N);
for(auto e : bridges)
{
int a = e.first;
int b = e.second;
adj[a].push_back(b);
adj[b].push_back(a);
}
while(total > 1)
{
dfs(1,1);
int res = query(to_ask);
if(res==1)
{
for(int i = 1 ; i <= N ; i++)
possible[i] &= asked[i];
}
else
for(auto v : to_ask)
possible[v] = false;
to_ask.clear();
counter = 0;
total = 0;
for(int i = 1 ; i <= N ; i++)
{
total += possible[i];
asked[i] = false;
}
}
}