Submission #1319953

#TimeUsernameProblemLanguageResultExecution timeMemory
1319953lknijikaijichiEaster Eggs (info1cup17_eastereggs)C++20
100 / 100
7 ms492 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; template <typename T> using vec = vector<T>; #define fi first #define sc second constexpr int maxn = 513; vec<vec<int>> adj(maxn); int timer = 0; vec<int> path(maxn); void dfs(int u, int p) { path[++timer] = u; for (int& v : adj[u]) { if (v != p) dfs(v, u); } } int findEgg (int n, vec<pair<int,int>> edges) { for (int i = 1; i <= n; ++i) { adj[i].clear(); } timer = 0; for (auto& edge : edges) { adj[edge.fi].push_back(edge.sc); adj[edge.sc].push_back(edge.fi); } dfs(1, 1); int lo = 1, hi = n; while (lo < hi) { int mid = (lo + hi) >> 1; vec<int> pt; for (int i = 1; i <= mid; ++i) pt.push_back(path[i]); if (query(pt)) hi = mid; else lo = mid + 1; } return path[lo]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...