# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67646 | tatatan | Easter Eggs (info1cup17_eastereggs) | C++11 | 48 ms | 624 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"
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;
vector<int> v[513];
int cnt,used[513],in[513];
void dfs(int x,int y,int en,vector<int> &add) {
if(cnt==en)
return;
add.pb(x);
in[x]=1;
if(!used[x]) ++cnt;
for(int i=0;i<v[x].size();++i)
if(v[x][i]!=y)
dfs(v[x][i],x,en,add);
}
int findEgg (int n, vector < pair < int, int > > br)
{
memset(used,0,sizeof used);
for(int i=1;i<=n;++i)
v[i].clear();
for(int i=0;i<n-1;++i) {
v[br[i].st].pb(br[i].nd);
v[br[i].nd].pb(br[i].st);
}
int left=n;
while(left!=1) {
vector<int> add;
cnt=0;
memset(in,0,sizeof in);
dfs(1,0,left/2,add);
/*cout<<left<<endl;
for(int i=0;i<add.size();++i)
cout<<add[i]<<" ";
cout<<endl;*/
if(query(add)) {
left=left/2;
for(int i=1;i<=n;++i)
if(!in[i]) used[i]=1;
}
else {
for(int i=0;i<add.size();++i)
used[add[i]]=1;
left-=left/2;
}
}
for(int i=1;i<=n;++i)
if(!used[i])
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... |