#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <string>
#include <set>
#include <utility>
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define ll long long
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define fr1(i, a, b) for (ll i = a - 1; i >= b; i--)
#define fi first
#define se second
#define mp(j, k) make_pair(j, k)
#define pb(x) push_back(x)
#define pbp(x, y) push_back({x, y})
#define in(x) insert(x)
#define vec vector<ll>
#define vecv vector<vector<ll> >
#define veb vector<bool>
#define vecp vector<pair<ll,ll>>
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define ac 1e-7
#define fauto(a) \
for (auto i : a) \
cout << i << " ";
#define fautop(a) \
for (auto i : a) \
cout << i.fi << " " << i.se << endl;
using namespace std;
int query(vector < int > islands);
int divide(int l, int r)
{
if(l == r) return l;
int mid = (l + r) / 2;
vector<int> left, right;
fr(i, l, mid + 1) left.pb(i);
fr(i, mid + 1, r + 1) right.pb(i);
if(query(left) == 1)
{
return divide(l, mid);
}
else
return divide(mid + 1, r);
}
int findEgg(int N, vector < pair < int, int > > bridges)
{
vector<vector<int> > adj(N + 1);
for(auto &p : bridges)
{
ll u = p.fi;
ll v = p.se;
adj[u].pb(v);
adj[v].pb(u);
}
return divide(1, N);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |