# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
242995 | nnnnnnnnnnnnnnnn | Easter Eggs (info1cup17_eastereggs) | C++14 | 6 ms | 640 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;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
int n,cnt,mid;
vector<vi> graph;
vi node;
vi no,yes;
void dfs(int start,int pa)
{
int i,j;
if(cnt==mid) return;
node.push_back(start);
if(no[start]==0) ++cnt;
for(i=0;i<graph[start].size();++i)
{
j = graph[start][i];
if(j!=pa)
{
dfs(j,start);
}
}
}
int findEgg(int n,vector<ii> edge)
{
int i,j;
graph.assign(n+1,vi());
no.assign(n+1,0);
yes.assign(n+1,0);
for(i=1;i<n;++i)
{
graph[edge[i].first].push_back(edge[i].second);
graph[edge[i].second].push_back(edge[i].first);
}
int curr = n;
while(curr!=1)
{
node.clear();
mid = curr/2;
cnt = 0;
dfs(1,-1);
if(query(node)==false)
{
for(i=0;i<node.size();++i)
{
no[node[i]] = 1;
}
curr -= node.size();
}
else
{
for(i=0;i<node.size();++i)
{
if(no[node[i]]==0)
{
yes[node[i]] = 1;
}
}
curr = mid;
}
}
for(i=1;i<=n;++i)
{
if(no[i]==0&&yes[i]==1)
{
return i;
}
}
}
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... |