#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int N = 600 + 7;
vector <int> g[N];
vector <int> path;
void dfs(int node, int p = - 1) {
path.push_back(node);
for (auto v : g[node]) {
if (v != p) {
dfs(v, node);
}
}
}
int findEgg (int n, vector <pair<int, int >> edges)
{
path.clear();
for (int i = 0; i <= n; i++) {
g[i].clear();
}
for (auto v : edges) {
g[v.first].push_back(v.second);
g[v.second].push_back(v.first);
}
dfs(1);
int l = 0, r = n;
// if this current path is ok, then look for more min answer
int ans = 0;
vector <int> lst;
while (l <= r) {
int mid = (l + r) >> 1;
lst.clear();
for (int i = 0; i <= mid; i++) {
lst.push_back(path[i]);
}
if (query(lst)) {
r = mid - 1;
ans = lst[mid];
}
else {
l = mid + 1;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
344 KB |
Number of queries: 5 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Number of queries: 8 |
2 |
Correct |
8 ms |
488 KB |
Number of queries: 9 |
3 |
Correct |
10 ms |
504 KB |
Number of queries: 9 |
4 |
Correct |
8 ms |
344 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
604 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
500 KB |
Number of queries: 9 |
3 |
Partially correct |
9 ms |
740 KB |
Number of queries: 10 |
4 |
Correct |
11 ms |
600 KB |
Number of queries: 9 |