# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095341 | idiotcomputer | Easter Eggs (info1cup17_eastereggs) | C++11 | 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.
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define sz(x) (int) (x).size()
const int mxN = 520;
vector<int> adj[mxN];
vector<int> ord;
int res = 0;
int k;
bool query(vector<int> cur){
res++;
for (int c : cur) if (c == k) return 1;
return 0;
}
void dfs(int node, int p){
ord.pb(node);
for (int c : adj[node]){
if (c != p) dfs(c,node);
}
}
int findEgg(int N, vector<pair<int,int>> bridges){
for (int i = 1; i <= N; i++) adj[i].clear();
ord.clear();
for (pair<int,int> c : bridges){
adj[c.f].pb(c.s);
adj[c.s].pb(c.f);
}
dfs(1,0);
int l = -1;
int r = N-1;
int cur;
while (r-l>1){
cur = (l+r)/2;
if (query(vector<int>(ord.begin(),ord.begin()+cur+1))) r = cur;
else l = cur;
}
return ord[r];
}