#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
const int inf = 1e3+9;
vector<int> DfsOrder,adj[inf];
void dfs(int u,int p){
DfsOrder.pb(u);
for(auto v:adj[u])
if(v != p)
dfs(v,u);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
for(int i=1;i<=n;i++)
adj[i].clear();
DfsOrder.clear();
for(auto o:bridges)
adj[o.first].pb(o.second),
adj[o.second].pb(o.first);
dfs(1,-1);
int l = 0,r = n-1;
while(r!=l){
int mid = (l+r)/2;
if(query(vector<int>(DfsOrder.begin(),DfsOrder.begin()+mid+1)))
r = mid;
else
l = mid+1;
}
return DfsOrder[l];
}
# |
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 |
472 KB |
Number of queries: 8 |
2 |
Correct |
17 ms |
460 KB |
Number of queries: 9 |
3 |
Correct |
19 ms |
356 KB |
Number of queries: 9 |
4 |
Correct |
16 ms |
360 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
328 KB |
Number of queries: 9 |
2 |
Correct |
18 ms |
352 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
356 KB |
Number of queries: 9 |
4 |
Correct |
19 ms |
328 KB |
Number of queries: 9 |