#include <bits/stdc++.h>
#include "grader.h"
#define pii pair<int, int>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
vector<int> adj[600];
vector<int> ord;
void dfs(int i, int prt) {
ord.pb(i);
for (auto j : adj[i]) {
if (j == prt) continue;
dfs(j, i);
}
}
int findEgg(int N, vector<pii> bridges) {
for (int i = 1; i <= 512; ++i) adj[i].clear();
ord.clear();
for (int i = 0; i < N - 1; ++i) {
int u = bridges[i].st;
int v = bridges[i].nd;
adj[u].pb(v);
adj[v].pb(u);
}
dfs(1, 0);
int l = 0, r = N-1;
while (l < r) {
int mid = (l+r)/2;
vector<int> check;
for (int i = 0; i <= mid; ++i) check.pb(ord[i]);
bool q = query(check);
if (q) r = mid;
else l = mid + 1;
}
return ord[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 |
1 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 |
5 ms |
336 KB |
Number of queries: 8 |
2 |
Correct |
11 ms |
356 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
14 ms |
336 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
364 KB |
Number of queries: 9 |
2 |
Correct |
15 ms |
360 KB |
Number of queries: 9 |
3 |
Correct |
20 ms |
464 KB |
Number of queries: 9 |
4 |
Correct |
15 ms |
352 KB |
Number of queries: 9 |