#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int n,l,r,md; vector <int> g[1000],a,b;
void dfs (int i,int p){
a.push_back(i);
for (int j:g[i]){
if (j==p) continue;
dfs(j,i);
}
}
int findEgg (int N, vector < pair < int, int > > bridges){
n=N; a.clear();
for (int i=1; i<=n; i++) g[i].clear();
for (auto i:bridges){
g[i.first].push_back(i.second);
g[i.second].push_back(i.first);
}
dfs(1,0);
l=0; r=n-1;
while (l<r){
md=(l+r)/2; b.clear();
for (int i=0; i<=md; i++)
b.push_back(a[i]);
if (query(b)) r=md;
else l=md+1;
}
return a[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
3 |
Correct |
0 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
0 ms |
344 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
344 KB |
Number of queries: 8 |
2 |
Correct |
6 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
9 ms |
600 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
532 KB |
Number of queries: 9 |
2 |
Correct |
8 ms |
504 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
488 KB |
Number of queries: 9 |
4 |
Correct |
9 ms |
600 KB |
Number of queries: 9 |