Submission #946814

#TimeUsernameProblemLanguageResultExecution timeMemory
946814PenguinsAreCuteEaster Eggs (info1cup17_eastereggs)C++17
100 / 100
13 ms1252 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; int pre[569], c; vector<int> adj[569]; void dfs(int x, int p) { pre[x] = c++; for(auto i: adj[x]) if(i!=p) dfs(i, x); } int findEgg (int N, vector < pair < int, int > > bridges) { for(int i=0;++i<=N;) adj[i].clear(); for(auto [u, v]: bridges) { adj[u].push_back(v); adj[v].push_back(u); } c=0; dfs(1,-1); int l=-1, r=N-1; while(r-l>1) { int m=l+r>>1; vector<int> v; for(int i=0;++i<=N;) if(pre[i]<=m) v.push_back(i); if(query(v)) r=m; else l=m; } for(int i=0;++i<=N;) if(pre[i]==r) return i; cout << "Beware the Ides of March\n"; return 69; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:19:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |   int m=l+r>>1;
      |         ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...