# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
243014 | daongocha | Easter Eggs (info1cup17_eastereggs) | C++14 | 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 <bits/stdc++.h>
#include "grader.h"
#define int long long
#define For(i,a,b) for (int i = a; i <= (b); i++)
#define For2(i,a,b) for (int i = a; i >= (b); i--)
#define pii pair<int, int>
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define INF 2147483647
#define EPS 1e-9
#define fi first
#define se second
//f#define FILEOPEN
using namespace std;
vector<int> path[515];
vector<int> passed;
void dfs(int u, int prev) {
passed.pb(u);
for (int v: path[u]) {
if (v == prev) continue;
dfs(v, u);
}
}
int findEgg(int n, vector<pii> bridges) {
For(i,1,n) path[i].clear();
for (pii a: bridges) {
path[a.fi].pb(a.se);
path[a.se].pb(a.fi);
}
passed.clear(); passed.pb(0);
dfs(1, 1);
int l = 1, r = n;
while (l < r) {
int mid = (l + r) / 2;
vector<int> a;
For(i,1,mid) a.pb(passed[i]);
if (query(a)) r = mid;
else l = mid + 1;
}
return passed[l];
}