#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 = 0, hi = n + 1;
while (lo + 1 < hi) {
int mid = (lo + hi + 1) / 2;
vector<int> lq;
for (int i = 1; i <= mid; ++i) {
assert(i - 1 < n);
lq.pb(order[i - 1]);
}
if (query(lq)) hi = mid;
else lo = mid;
}
return order[hi - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
200 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
200 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
200 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
200 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
328 KB |
Number of queries: 8 |
2 |
Correct |
12 ms |
344 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
328 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
16 ms |
368 KB |
Number of queries: 10 |
2 |
Correct |
13 ms |
344 KB |
Number of queries: 9 |
3 |
Partially correct |
17 ms |
448 KB |
Number of queries: 10 |
4 |
Partially correct |
19 ms |
348 KB |
Number of queries: 10 |