#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int maxn = 2055;
vector < int > g[maxn], q;
void dfs(int v, int p) {
q.push_back(v);
for (int to : g[v])
if (to != p)
dfs(to, v);
}
int findEgg(int N, vector < pair < int, int > > bridges) {
q.clear();
for (int i = 1; i <= N; i++)
g[i].clear();
for (auto it : bridges) {
g[it.first].push_back(it.second);
g[it.second].push_back(it.first);
}
dfs(1, -1);
int l = 0, r = N;
while (r - l > 1) {
int m = (l + r) / 2;
if (query(vector < int >(q.begin(), q.begin() + m)))
r = m;
else
l = m;
}
return q[r - 1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
248 KB |
Number of queries: 4 |
2 |
Correct |
6 ms |
248 KB |
Number of queries: 4 |
3 |
Correct |
6 ms |
248 KB |
Number of queries: 4 |
4 |
Correct |
6 ms |
248 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
376 KB |
Number of queries: 8 |
2 |
Correct |
17 ms |
376 KB |
Number of queries: 9 |
3 |
Correct |
22 ms |
376 KB |
Number of queries: 9 |
4 |
Correct |
27 ms |
380 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
376 KB |
Number of queries: 9 |
2 |
Correct |
35 ms |
376 KB |
Number of queries: 9 |
3 |
Correct |
24 ms |
376 KB |
Number of queries: 9 |
4 |
Correct |
39 ms |
376 KB |
Number of queries: 9 |