#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> adj[513], tmp;
int idx[513], cnt = 0;
void dfs(int a, int p){
idx[++cnt] = a;
for(auto x : adj[a]){
if(x == p) continue;
dfs(x, a);
}
return;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
memset(idx, 0, sizeof idx);
for(int i = 1; i <= N; i++) adj[i].clear();
cnt = 0;
for(auto x : bridges){
adj[x.first].push_back(x.second);
adj[x.second].push_back(x.first);
}
dfs(1, 0);
int l = 1, r = N;
while(l < r){
int mid = (l + r) >> 1;
for(int i = 1; i <= mid; i++) tmp.push_back(idx[i]);
int q = query(tmp);
if(q) r = mid;
else l = mid + 1;
tmp.clear();
}
return idx[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
2 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
3 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
340 KB |
Number of queries: 8 |
2 |
Correct |
13 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
17 ms |
340 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
336 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
360 KB |
Number of queries: 9 |
2 |
Correct |
16 ms |
352 KB |
Number of queries: 9 |
3 |
Correct |
23 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
360 KB |
Number of queries: 9 |