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"
using namespace std;
const int N = 512;
vector<int> adj[N];
vector<int> order;
void dfs(int node, int p = -1){
order.emplace_back(node);
for (int i:adj[node]){
if (i != p){
dfs(i,node);
}
}
}
int findEgg (int N, vector < pair < int, int > > bridges){
for (int i=0; i<N; ++i){
adj[i].clear();
}
order.clear();
for (auto [a,b]:bridges){
a--; b--;
adj[a].emplace_back(b);
adj[b].emplace_back(a);
}
dfs(0);
int deb = 0, fin = N-1;
while (deb < fin){
int mid = (deb+fin)/2;
vector<int> q;
for (int i=0; i<=mid; ++i){
q.emplace_back(order[i]+1);
}
if (query(q)){
fin = mid;
}
else{
deb = mid+1;
}
}
return order[deb]+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |