Submission #522735

#TimeUsernameProblemLanguageResultExecution timeMemory
522735Theo830Easter Eggs (info1cup17_eastereggs)C++17
100 / 100
23 ms408 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>()); tim = 0; 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; ll ans = r; while(l <= r){ ll mid = (l+r)/2; vector<int>exo; if(l == ans){ break; } f(i,0,mid + 1){ exo.pb(arr[i]); } if(query(exo)){ r = mid - 1; ans = min(ans,mid); } else{ l = mid + 1; } } return arr[ans]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...