# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547311 | Monarchuwu | Easter Eggs (info1cup17_eastereggs) | C++17 | 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.
/**
* Problem: info1cup17_eastereggs - Easter Eggs
* Link: https://oj.uz/problem/view/info1cup17_eastereggs
* Tags: Interactive
**/
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
//#include "grader.h"
using namespace std;
typedef pair<int, int> pii;
#define ff first
#define ss second
const int N = 600;
vector<int> g[N], ord;
void dfs(int u, int p) {
ord.push_back(u);
for (int v : g[u])
if (v != p) dfs(v, u);
}
int findEgg(int n, vector<pii> bridges) {
for (int i = 1; i <= n; ++i) g[i].clear();
for (pii e : bridges) {
g[e.ff].push_back(e.ss);
g[e.ss].push_back(e.ff);
}
ord.clear();
dfs(1, 0);
int lo(0), hi(n - 2), m;
while (lo <= hi) {
m = (lo + hi) >> 1;
if (query(vector<int>(ord.begin(), ord.begin() + m + 1)))
hi = m - 1;
else lo = m + 1;
}
return ord[hi + 1];
}