#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
a.pb(i);
for (int c:adj[i]){
if (c != p)
dfs(c,i);
}
}
int findEgg(int n,vector<pair<int,int>>b)
{
for (int i = 0;i<=512;i++)adj[i].clear();
a.clear();
for (pair<int,int> i : b)adj[i.first].pb(i.second),adj[i.second].pb(i.first);
dfs(1,1);
int l = 0,r = n - 1;
while (l < r){
int mid = (l + r + 1)/2;
if (query(vector<int>(a.begin(),a.begin() + mid))){
r = mid - 1;
}
else l = mid;
}
return a[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
364 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
364 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
364 KB |
Number of queries: 4 |
4 |
Correct |
2 ms |
364 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
364 KB |
Number of queries: 8 |
2 |
Correct |
13 ms |
364 KB |
Number of queries: 9 |
3 |
Correct |
22 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
492 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
384 KB |
Number of queries: 9 |
2 |
Correct |
17 ms |
428 KB |
Number of queries: 9 |
3 |
Correct |
24 ms |
364 KB |
Number of queries: 9 |
4 |
Correct |
24 ms |
364 KB |
Number of queries: 9 |