Submission #979258

#TimeUsernameProblemLanguageResultExecution timeMemory
979258c2zi6Easter Eggs (info1cup17_eastereggs)C++14
100 / 100
18 ms1800 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "grader.h" int n; VVI gp; VI euler; void dfs(int u = 0, int p = -1) { euler.pb(u+1); for (int v : gp[u]) if (v != p) dfs(v, u); } bool qr(int x) { VI tmp; replr(i, 0, x) tmp.pb(euler[i]); return query(tmp); } int findEgg(int N, VPI bridges) { n = N; gp = VVI(n); for (auto[u, v] : bridges) { u--, v--; gp[u].pb(v); gp[v].pb(u); } dfs(); int l = -1, r = n-1; while (l + 1 < r) { int m = (l + r) / 2; if (qr(m)) r = m; else l = m; } return euler[r]; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, VPI)':
eastereggs.cpp:52:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |  for (auto[u, v] : bridges) {
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...