#ifdef LC
#include "pch.h"
#else
#include <bits/stdc++.h>
#endif
using namespace std;
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple
int query(vector<int>);
const int N = 1e3;
vector<int> g[N];
vector<int> order;
void dfs(int v) {
order.push_back(v);
for (int u : g[v]) {
g[u].erase(find(all(g[u]), v));
dfs(u);
}
}
bool check(int pref) {
vector<int> cur;
for (int i = 0; i < pref; ++i) {
cur.push_back(order[i]);
}
return (bool)query(cur);
}
int findEgg(int n, vector<pair<int, int>> edges) {
fill_n(g, n, vector<int>());
for (auto e : edges) {
g[e.x].push_back(e.y);
g[e.y].push_back(e.x);
}
order.clear();
dfs(0);
int lef = 0, rig = (int)order.size();
while (rig - lef > 1) {
int mid = (lef + rig) / 2;
if (check(mid)) {
rig = mid;
} else {
lef = mid;
}
}
return lef;
}
#ifdef LC
int query(vector<int>) {
return 0;
}
signed main() {
assert(freopen("input.txt", "r", stdin));
ios::sync_with_stdio(0); cin.tie(0);
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
The found island is incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
364 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |