#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, mid=0, cnt=-1;
while(l<=r){
mid = md;
if(Q(mid)){ cnt = mid; r = mid-1; }
else l = mid+1;
}
if(cnt==-1) assert(false);
for(int i=0; i<=n+1; i++) adj[i].clear();
return arr[cnt];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
3 ms |
15704 KB |
Number of queries: 5 |
2 |
Partially correct |
3 ms |
15704 KB |
Number of queries: 5 |
3 |
Partially correct |
3 ms |
15840 KB |
Number of queries: 5 |
4 |
Partially correct |
2 ms |
15704 KB |
Number of queries: 5 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
15960 KB |
Number of queries: 9 |
2 |
Correct |
12 ms |
15964 KB |
Number of queries: 9 |
3 |
Correct |
12 ms |
15964 KB |
Number of queries: 9 |
4 |
Correct |
13 ms |
15972 KB |
Number of queries: 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
11 ms |
15960 KB |
Number of queries: 10 |
2 |
Correct |
12 ms |
16464 KB |
Number of queries: 9 |
3 |
Partially correct |
13 ms |
15976 KB |
Number of queries: 10 |
4 |
Partially correct |
13 ms |
15968 KB |
Number of queries: 10 |