#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int>adj[1000],a;
void dfs(int v,int u){
a.push_back(v);
for(int x:adj[v]){
if(x==u)continue;
dfs(x,v);
}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
a.clear();
for(int i=1;i<=n;i++)adj[i].clear();
for(auto x:bridges){
adj[x.first].push_back(x.second);
adj[x.second].push_back(x.first);
}
dfs(1,0);
int l = 0,r = n-1;
while(r>l){
int mid = (l+r)/2;
vector<int>b;
for(int i=0;i<=mid;i++)b.push_back(a[i]);
if(query(b))r=mid;
else l=mid+1;
}
return a[r];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
348 KB |
Number of queries: 8 |
2 |
Correct |
11 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
356 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
360 KB |
Number of queries: 9 |
2 |
Correct |
14 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
328 KB |
Number of queries: 9 |