Submission #691894

# Submission time Handle Problem Language Result Execution time Memory
691894 2023-01-31T22:07:16 Z Ahmed_Solyman Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
24 ms 564 KB
#include <bits/stdc++.h>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_cxx;
#pragma GCC optimize("-Ofast")
#pragma GCC optimize("-O1")
//-------------------------------------------------------------//
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sum_to(n) (n*(n+1))/2
#define pb push_back
#define pf push_front
#define sz size()
#define fil(arr,x) memset(arr,x,sizeof(arr))
const ll mod=1e9+7;
int dx[8]={0,1,0,-1,1,1,-1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
//-------------------------------------------------------------//
ll lcm(ll a,ll b)
{
    return (max(a,b)/__gcd(a,b))*min(a,b);
}
void person_bool(bool x)
{
    cout<<(x?"YES":"NO")<<endl;
}
vector<int>v;
int query(vector<int>v);
int findEgg(int n,vector<pair<int,int>>f){
	vector<int>adj[n+5];
	for(auto i:f){
		adj[i.first].pb(i.second);
		adj[i.second].pb(i.first);
	}
	queue<int>q;
	q.push(1);
	vector<bool>vis(n+5);
	while(q.sz){
		int x=q.front();
		q.pop();v.pb(x);
		vis[x]=1;
		for(auto i:adj[x]){
			if(!vis[i]){
				q.push(i);
			}
		}
	}
	int l=1,r=n-1;
	int ans=0;
	while(l<=r){
		int mid=(l+r)/2;
		vector<int>g;
		for(int i=0;i<mid;i++){
			g.pb(v[i]);
		}
		if(query(g)){
			r=mid-1;
		}
		else{
			ans=mid;
			l=mid+1;
		}
	}
	return v[ans];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 5 ms 356 KB Number of queries: 8
2 Correct 16 ms 456 KB Number of queries: 9
3 Correct 24 ms 544 KB Number of queries: 9
4 Correct 16 ms 468 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 17 ms 540 KB Number of queries: 9
2 Correct 23 ms 456 KB Number of queries: 9
3 Correct 18 ms 564 KB Number of queries: 9
4 Correct 18 ms 464 KB Number of queries: 9