#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int n;
vector<int> adj[555], arr;
void dfs(int i, int p) {
arr.push_back(i);
for (int j : adj[i]) {
if (j == p) {
continue;
}
dfs(j, i);
}
}
int findEgg (int N, vector<pair<int, int>> bridges) {
int n = N;
for (int i = 1; i <= n; i++) {
adj[i].clear();
}
arr.clear();
for (auto [a, b] : bridges) {
adj[a].push_back(b);
adj[b].push_back(a);
}
int l = 1, r = n;
dfs(1, -1);
while(l < r) {
int m = (l+r)/2;
vector<int> b;
for (int i = 0; i < m; i++) {
b.push_back(arr[i]);
}
if (query(b)) {
r = m;
} else {
l = m+1;
}
}
return arr[l-1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
344 KB |
Number of queries: 4 |
4 |
Correct |
0 ms |
344 KB |
Number of queries: 4 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Number of queries: 8 |
2 |
Correct |
8 ms |
600 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
344 KB |
Number of queries: 9 |
4 |
Correct |
8 ms |
484 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
344 KB |
Number of queries: 9 |
2 |
Correct |
8 ms |
492 KB |
Number of queries: 9 |
3 |
Correct |
9 ms |
600 KB |
Number of queries: 9 |
4 |
Correct |
9 ms |
344 KB |
Number of queries: 9 |