This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
// #pragma GCC optimize("O3", "unroll-loops")
#include "grader.h"
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii, int> ipii;
const int MAXN = 5e5+10;
const int MAXA = 9e3+20;
const ll INF = 1e9+10;
const int LOG = 20;
const int SQRT = 450;
const vector<int> NOL = {};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const vector<int> dx = {1, -1, 0, 0};
const vector<int> dy = {0, 0, 1, -1};
vector <int> key = {29, 31};
vector <int> mod = {998244353, 1000000007};
void chmx(int &a, int b){ a = max(a, b); }
int n;
vector <int> adj[MAXN];
int in[MAXN], tim, arr[MAXN];
void dfs(int nw, int par){
in[nw] = ++tim; arr[tim] = nw;
for(auto nx : adj[nw]){
if(nx==par) continue;
dfs(nx, nw);
}
}
bool Q(int x){
vector <int> vec;
for(int i=1; i<=x; i++) vec.pb(arr[i]);
return query(vec);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
n = N;
for(auto in : bridges){ adj[in.fi].pb(in.se); adj[in.se].pb(in.fi); }
tim = 0;
dfs(1, 0);
int l=1, r=n-1, mid=0, cnt=n;
while(l<=r){
mid = md;
if(Q(mid)){ cnt = mid; r = mid-1; }
else l = mid+1;
}
for(int i=0; i<=n+1; i++) adj[i].clear();
return arr[cnt];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |