#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
vector<vector<ll>>g;
vector<ll>check,order;
void dfs(ll node){
check[node]=1;
for(ll i:g[node]){
if(!check[node])
dfs(node);
}
order.pb(node);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
g.resize(n+10);
for(ll i=0;i<n;i++){
g[bridges[i].ff].pb(bridges[i].ss);
g[bridges[i].ss].pb(bridges[i].ff);
}
reverse(order.begin(),order.end());
check.resize(n+10);
dfs(1);
ll l=0,r=n-1;
while(l<r){
ll mid=(l+1+r)/2;
if(query(vector<int>(order.begin(),order.begin()+mid)))
r=mid-1;
else
l=mid;
}
return order[l];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |