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>
using namespace std;
typedef long long ll;
//#define int ll
#include "grader.h"
vector<int> roads[515];
int nextnode=1, val[515];
void dfs(int x, int p){
val[nextnode] = x;
nextnode++;
for(int i:roads[x]){
if(i!=p){
dfs(i,x);
}
}
}
int findEgg(int n, vector<pair<int,int>> bridges){
for(pair<int,int> i:bridges){
roads[i.first].push_back(i.second);
roads[i.second].push_back(i.first);
}
dfs(1,0);
int low=1,high=n,mid;
while(low!=high){
mid = (low+high)/2;
vector<int> x;
for(int i=1;i<=mid;i++){
x.push_back(val[i]);
}
if(query(x)){
high = mid;
}
else{
low = mid+1;
}
}
int ans=val[low];
nextnode = 1;
for(int i=1;i<=n;i++){
roads[i].clear();
val[i] = 0;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |