#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> g[555];
vector<int> vertex;
void dfs(int v, int p = -1) {
vertex.push_back(v);
for (auto to : g[v]) {
if (to != p) {
dfs(to, v);
}
}
}
int check(int len) {
}
int findEgg (int N, vector < pair < int, int > > bridges){
vector<vector<int>> g(N);
vector<int> vertex;
for (auto it : bridges) {
g[it.first - 1].push_back(it.second - 1);
g[it.second - 1].push_back(it.first - 1);
}
function<void(int,int)> dfs = [&](int v, int p) {
vertex.push_back(v);
for (int to : g[v]) {
if (to != p) {
dfs(to, v);
}
}
};
dfs(0, -1);
int l = 0, r = vertex.size() - 1;
while (l < r) {
int m = (l + r) / 2;
vector<int> Q;
for (int i = 0; i <= m; i++) Q.push_back(vertex[i] + 1);
if (query(Q) == 1)
r = m;
else
l = m + 1;
}
return vertex[r] + 1;
}
Compilation message
eastereggs.cpp: In function 'int check(int)':
eastereggs.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
19 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
2 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
3 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
4 |
Correct |
1 ms |
200 KB |
Number of queries: 4 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
356 KB |
Number of queries: 8 |
2 |
Correct |
11 ms |
328 KB |
Number of queries: 9 |
3 |
Correct |
21 ms |
328 KB |
Number of queries: 9 |
4 |
Correct |
20 ms |
328 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
396 KB |
Number of queries: 9 |
2 |
Correct |
15 ms |
448 KB |
Number of queries: 9 |
3 |
Correct |
16 ms |
340 KB |
Number of queries: 9 |
4 |
Correct |
17 ms |
348 KB |
Number of queries: 9 |