Submission #522728

#TimeUsernameProblemLanguageResultExecution timeMemory
522728Theo830Easter Eggs (info1cup17_eastereggs)C++17
0 / 100
4 ms488 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "grader.h" vector<vector<ll> >adj; ll arr[600]; ll tim = 0; void dfs(ll idx,ll p){ arr[tim] = idx; tim++; for(auto x:adj[idx]){ if(x != p){ dfs(x,idx); } } } int findEgg(int N, vector < pair < int, int > > bridges){ adj.assign(N+5,vector<ll>()); for(auto x:bridges){ adj[x.F].pb(x.S); adj[x.S].pb(x.F); } dfs(1,0); ll l = 0,r = N-1; while(1){ ll mid = (l+r)/2; vector<int> exo; f(i,0,mid){ exo.pb(arr[i]); } if(query(exo)){ if(exo.size() == 1){ return exo[0]; } r = mid - 1; } else{ l = mid; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...