#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define fi first
#define se second
typedef pair<double, double> iid;
typedef pair<int, int> ii;
const int N = 600;
const int oo = 1e9;
int n, cnt;
int pos[N];
vector<int> vi[N];
void dfs(int pre, int u) {
pos[++cnt] = u;
for(int v: vi[u]) if(v != pre)
dfs(u, v);
}
int findEgg(int num, vector< pair<int, int> > bridges){
cnt = 0; n = num;
for(int i = 1; i <= n; ++i) vi[i].clear();
for(auto v: bridges) {
vi[v.fi].pb(v.se); vi[v.se].pb(v.fi);
}
dfs(1, 1);
int l = 1, r = n;
while(r != l) {
int mid = (l + r) / 2;
vector<int> tmp;
for(int i = 1; i <= mid; ++i)
tmp.pb(pos[i]);
if(query(tmp)) r = mid;
else l = mid + 1;
}
return pos[l];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Number of queries: 4 |
2 |
Correct |
4 ms |
376 KB |
Number of queries: 4 |
3 |
Correct |
3 ms |
376 KB |
Number of queries: 4 |
4 |
Correct |
3 ms |
492 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
628 KB |
Number of queries: 8 |
2 |
Correct |
25 ms |
628 KB |
Number of queries: 9 |
3 |
Correct |
44 ms |
628 KB |
Number of queries: 9 |
4 |
Correct |
30 ms |
628 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
628 KB |
Number of queries: 9 |
2 |
Correct |
24 ms |
628 KB |
Number of queries: 9 |
3 |
Correct |
33 ms |
628 KB |
Number of queries: 9 |
4 |
Correct |
30 ms |
628 KB |
Number of queries: 9 |