This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// trans rights
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> adj[1069];
vector<int> H;
void dfs(int i, int p)
{
H.push_back(i);
for (int j : adj[i])
{
if (j == p) continue;
dfs(j, i);
}
}
bool within(int x)
{
vector<int> q;
for (int i = 0; i <= x; i++)
q.push_back(H[i]);
return query(q);
}
int findEgg(int N, vector<pair<int, int>> bridges)
{
for (auto &a : adj)
a.clear();
H.clear();
for (int i = 0; i < N - 1; i++)
{
int a = bridges[i].first;
int b = bridges[i].second;
adj[a].push_back(b);
adj[b].push_back(a);
}
dfs(1, 1);
int a = 0;
int b = N;
while (b - a > 1)
{
int m = (a + b) / 2;
if (within(m - 1)) b = m;
else a = m;
}
return H[a];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |