Submission #1019032

# Submission time Handle Problem Language Result Execution time Memory
1019032 2024-07-10T12:11:55 Z ByeWorld Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
19 ms 16216 KB
#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
1 Correct 3 ms 15704 KB Number of queries: 4
2 Correct 3 ms 15704 KB Number of queries: 4
3 Correct 3 ms 15704 KB Number of queries: 4
4 Correct 3 ms 15704 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15964 KB Number of queries: 8
2 Correct 9 ms 16216 KB Number of queries: 9
3 Correct 19 ms 15960 KB Number of queries: 9
4 Correct 14 ms 16216 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 15960 KB Number of queries: 9
2 Correct 11 ms 15960 KB Number of queries: 9
3 Correct 12 ms 15976 KB Number of queries: 9
4 Correct 11 ms 15976 KB Number of queries: 9