Submission #691891

# Submission time Handle Problem Language Result Execution time Memory
691891 2023-01-31T22:01:37 Z Ahmed_Solyman Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
23 ms 556 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;
	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 Partially correct 1 ms 300 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 7 ms 344 KB Number of queries: 9
2 Correct 11 ms 460 KB Number of queries: 9
3 Correct 18 ms 528 KB Number of queries: 9
4 Correct 15 ms 464 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 16 ms 444 KB Number of queries: 10
2 Correct 17 ms 460 KB Number of queries: 9
3 Partially correct 23 ms 548 KB Number of queries: 10
4 Partially correct 19 ms 556 KB Number of queries: 10