# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80820 | 2018-10-22T12:31:47 Z | farukkastamonuda | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000000 #define md 1000000007 #define li 530 #define mp make_pair #define pb push_back using namespace std; int cur,mark[li], now; vector<int> v[li], send; void dfs(int node,int ata){ if(now==cur/2) return ; now += (! mark[node]); send.pb(node); for(int i = 0;i < (int)v[node].size(); i++){ int go = v[node][i]; if(go != ata) dfs(go,node); } } int findEgg(int N, vector< pair<int, int> > bridges){ for(int i = 0; i < N - 1; i++){ int x = bridges[i].fi; int y = bridges[i].se; v[x].pb(y); v[y].pb(x); } cur = N; while(cur > 1){ now = 0; dfs(1, 0); if(query(send) == 1){ cur /= 2; for(int i = 1;i <= N ; i++){ mark[i] = 1; } for(int i = 0;i < (int)send.size(); i++){ mark[send[i]] = 0; } } else{ cur = cur - cur / 2; for(int i = 0;i < (int)send.size(); i++){ mark[send[i]]=1; } } send.clear(); } for(int i = 1;i <= N; i++){ if(mark[i] == 0) return i; } }