/*
Coded by thegamercoder19
GL
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include "grader.h"
#define M_PI 3.14159265358979323846
#define FILER 0
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = pow(10, 9) + 7;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const ull INFUL = 0x3f3f3f3f3f3f3f3f;
const ll INFT = 0x3f3f3f3f;
const ull MAX = 1LL << 24;
const ll MODD = 998244353;
const double EPS = 1e-10;
#define V vector
#define pll pair<ll, ll>
#define pull2 pair<ull,ull>
#define MS multiset
#define M map
#define Q queue
#define PQ priority_queue
#define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c)
#define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c)
#define FORA(a,i) for(auto &i : a)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define sorta(a) sort(all(a))
#define sortd(a) sort(all(a), greater<ll>())
#define setp(x) setprecision(x)<<fixed
#define RET return
#define log(a,b) log(b)/log(a)
#define WH(s) while(s)
#define WHI(t) WH(t--)
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define YESNO(s) cout << (s ? "YES" : "NO") << endl;
#define YesNo(s) cout<<(s?"Yes":"No")<<endl;
#define TYP 0
using namespace std;
ll l, r, m, ans;
V<V<ll>> g;
V<ll> orr;
V<bool> used;
void dfs(ll u)
{
orr.push_back(u);
used[u] = 1;
FORA(g[u], v)if (!used[v])dfs(v);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
l = 0, r = N - 1;
V<V<ll>>().swap(g); V<ll>().swap(orr); V<bool>().swap(used);
ans = -1;
g.resize(N + 1); used.resize(N + 1);
FORA(bridges, u)g[u.first].push_back(u.second), g[u.second].push_back(u.first);
dfs(1);
WH(l <= r)
{
m = (l + r) >> 1;
if (!query(V<int>(orr.begin(), orr.begin() + m + 1)))l = m + 1;
else ans = orr[m], r = m - 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
2 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
3 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
4 |
Partially correct |
1 ms |
208 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
336 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
348 KB |
Number of queries: 9 |
3 |
Correct |
17 ms |
348 KB |
Number of queries: 9 |
4 |
Correct |
21 ms |
340 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
16 ms |
364 KB |
Number of queries: 10 |
2 |
Correct |
19 ms |
348 KB |
Number of queries: 9 |
3 |
Partially correct |
17 ms |
348 KB |
Number of queries: 10 |
4 |
Partially correct |
15 ms |
356 KB |
Number of queries: 10 |