#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> o;
void order(int x, int t, vector<vector<int>> v) {
o.push_back(x);
for (int i : v[x]) {
if (i == t)
continue;
order(i, x, v);
}
}
int findEgg(int N, vector < pair < int, int > > bridges) {
vector<vector<int>> g(N+1);
for (auto p : bridges) {
int u = p.first, v = p.second;
g[u].push_back(v);
g[v].push_back(u);
}
order(1, -1, g);
int l = 0, r = N-2, mid, x = N-1;
while (l <= r) {
mid = (l+r)/2;
vector<int> a;
for (int i=0; i<=mid; i++)
a.push_back(o[i]);
if (query(a)) {
r = mid-1;
x = mid;
} else {
l = mid+1;
}
}
int ans = o[x];
o.clear();
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
208 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
78 ms |
3408 KB |
Number of queries: 8 |
2 |
Correct |
327 ms |
636 KB |
Number of queries: 9 |
3 |
Execution timed out |
557 ms |
2296 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
620 ms |
14336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |