Submission #1124456

#TimeUsernameProblemLanguageResultExecution timeMemory
1124456gdragonEaster Eggs (info1cup17_eastereggs)C++20
87 / 100
13 ms2928 KiB
#include <bits/stdc++.h> using namespace std; #include"grader.h" #define TASK "long" #define fi first #define se second #define ll long long #define pb push_back #define ALL(x) (x).begin(), (x).end() #define GETBIT(mask, i) ((mask) >> (i) & 1) #define MASK(i) ((1LL) << (i)) #define SZ(x) ((int)(x).size()) #define mp make_pair #define CNTBIT(mask) __builtin_popcount(mask) template<class X, class Y> bool maximize(X &x, Y y){ if (x < y) {x = y; return true;} return false;}; template<class X, class Y> bool minimize(X &x, Y y){ if (x > y) {x = y; return true;} return false;}; typedef pair<int, int> ii; const int N = 1e5 + 5; const int inf = 1e9 + 7; const long long INF = (long long)1e18 + 7; const int mod = 1e9 + 7; void add(int &x, int y) {x += y; if (x >= mod) x -= mod;} void sub(int &x, int y) {x -= y; if (x < 0) x += mod;} int mul(int x, int y) {return 1LL * x * y % mod;} // -----------------------------------------// int n; vector<int> adj[N]; int tin[N], node[N]; int timer = 0; void dfs(int u, int p) { tin[u] = ++timer; node[timer] = u; for(int v: adj[u]) if (v != p) { dfs(v, u); } } int findEgg(int N, vector<pair<int, int>> bridges) { n = N; int root = 0; for(auto [u, v]: bridges) { root = u; adj[u].push_back(v); adj[v].push_back(u); } dfs(root, -1); vector<int> islands; int l = 1, r = n, ans = 0; while(l <= r) { int mid = (l + r) >> 1; while(SZ(islands) < mid) islands.push_back(node[SZ(islands) + 1]); while(SZ(islands) > mid) islands.pop_back(); if (query(islands) == 1) { ans = node[mid]; r = mid - 1; } else l = mid + 1; } for(int i = 1; i <= n; i++) adj[i].clear(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...