#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
using namespace std;
#include "grader.h"
vector<int> adj[1000];
vector<int> sub(1000);
vector<bool> let(1000, false);
void dfs(int x, int pre){
sub[x] = 1;
for(auto y : adj[x]){
if(y == pre || !let[y]) continue;
dfs(y, x);
sub[x] += sub[y];
}
}
void addall(int x, int pre, vector<int>& A){
A.pb(x);
for(auto y : adj[x]){
if(y == pre || !let[y]) continue;
addall(y, x, A);
}
}
void split(int x, int pre, int s, vector<int>&L,vector<int>&R){
L.pb(x);
R.pb(x);
s--;
for(auto y : adj[x]){
if(y == pre || !let[y]) continue;
if(s >= sub[y]){
addall(y, x, L);
s -= sub[y];
}
else {
addall(y, x, R);
}
}
}
int solve(vector<int> comp){
if(comp.empty()) assert(0);
int root = comp[0];
if(sz(comp) == 1) return root;
vector<int> left, right;
for(auto x : comp) let[x] = true;
dfs(root, -1);
split(root, -1, 24, left, right);
for(auto x : comp) let[x] = false;
if(right.size() == 1){
for(auto x : left){
if(query({x})) return x;
}
assert(0);
}
if(query(left)){
return solve(left);
}
else {
return solve(right);
}
}
void init(vector < pair < int, int > >& bridges){
static bool yes = true;
if(yes)
for(auto p : bridges){
adj[p.first].pb(p.second);
adj[p.second].pb(p.first);
}
yes = false;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
init(bridges);
vector<int> arr;
for(int i = 1; i <= N; i++) arr.pb(i);
return solve(arr);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
384 KB |
Number of queries: 16 |
2 |
Partially correct |
2 ms |
384 KB |
Number of queries: 16 |
3 |
Partially correct |
3 ms |
384 KB |
Number of queries: 16 |
4 |
Partially correct |
2 ms |
384 KB |
Number of queries: 16 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |