#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
#include "grader.h"
vector<int> adj[520], order;
void dfs(int x, int p) {
order.pb(x);
for (auto i: adj[x]) {
if (i == p) continue;
dfs(i, x);
}
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
order.clear();
for (int i = 1; i <= n; ++i) adj[i].clear();
for (auto i: bridges) {
adj[i.fi].pb(i.si);
adj[i.si].pb(i.fi);
}
dfs(1, -1);
int lo = 1, hi = n;
while (lo != hi) {
int mid = (lo + hi) / 2;
vector<int> lq;
for (int i = 1; i <= mid; ++i) {
assert(i - 1 < n);
lq.pb(order[i - 1]);
}
// if (lo + 1 == mid) return order[mid - 1];
// cerr<<lo<<' '<<mid<<' '<<hi<<'\n';
if (query(lq)) hi = mid;
else lo = mid + 1;
}
// cerr<<order[hi - 1]<<'\n';
return order[hi - 1];
}
# |
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 |
4 ms |
328 KB |
Number of queries: 8 |
2 |
Correct |
10 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
332 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
340 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
356 KB |
Number of queries: 9 |
2 |
Correct |
13 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
352 KB |
Number of queries: 9 |
4 |
Correct |
15 ms |
352 KB |
Number of queries: 9 |