#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
typedef long long ll;
vector<int> g[1010], ans;
void dfs(int u, int p) {
ans.push_back(u);
for (auto &v : g[u])
if (v != p)
dfs(v, u);
}
int findEgg (int n, vector<pair<int, int>> bridges) {
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, 0);
int l = 0, r = n - 2;
while (l <= r) {
int m = (l + r) / 2;
if (query(vector<int>(ans.begin(), ans.begin() + m + 1)))
r = m - 1;
else
l = m + 1;
}
return ans[l];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
600 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
460 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
464 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Number of queries: 8 |
2 |
Correct |
8 ms |
1256 KB |
Number of queries: 9 |
3 |
Correct |
13 ms |
1044 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
908 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
916 KB |
Number of queries: 9 |
2 |
Correct |
9 ms |
616 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
1204 KB |
Number of queries: 9 |
4 |
Correct |
10 ms |
856 KB |
Number of queries: 9 |