#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 515;
vector <int> g[N], vertices;
int n, a[N];
void dfs (int u, int p) {
vertices.push_back(u);
for (int v: g[u]) {
if (v == p) continue;
dfs(v, u);
}
}
int findEgg (int N, vector <pair <int, int> > bridges) {
n = N;
vertices.clear();
for (int i = 1; i <= n; i++) g[i].clear();
for (auto i: bridges) {
g[i.first].push_back(i.second);
g[i.second].push_back(i.first);
}
dfs(1, 1);
int l = 1;
int r = n;
vector <int> islands;
while (l < r) {
int mid = (l + r) / 2;
islands.clear();
for (int i = 1; i <= mid; i++) {
islands.push_back(vertices[i - 1]);
}
if (query(islands)) r = mid;
else l = mid + 1;
}
return vertices[r - 1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
248 KB |
Number of queries: 4 |
2 |
Correct |
3 ms |
436 KB |
Number of queries: 4 |
3 |
Correct |
3 ms |
436 KB |
Number of queries: 4 |
4 |
Correct |
5 ms |
436 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
492 KB |
Number of queries: 8 |
2 |
Correct |
32 ms |
492 KB |
Number of queries: 9 |
3 |
Correct |
29 ms |
496 KB |
Number of queries: 9 |
4 |
Correct |
18 ms |
604 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
604 KB |
Number of queries: 9 |
2 |
Correct |
24 ms |
604 KB |
Number of queries: 9 |
3 |
Correct |
25 ms |
608 KB |
Number of queries: 9 |
4 |
Correct |
35 ms |
608 KB |
Number of queries: 9 |