제출 #1127076

#제출 시각아이디문제언어결과실행 시간메모리
1127076gygEaster Eggs (info1cup17_eastereggs)C++17
100 / 100
10 ms500 KiB
#include "grader.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define fir first #define sec second #define vec vector #define arr array const int N = 6e2 + 5; int n; arr<vec<int>, N> adj; int nm_ids; arr<int, N> id, rv_id; void dfs(int u = 1) { id[u] = ++nm_ids, rv_id[id[u]] = u; for (int v : adj[u]) if (!id[v]) dfs(v); } bool chck(int i) { vec<int> qry; for (int j = 1; j <= i; j++) qry.push_back(rv_id[j]); return query(qry); } int srch() { int lw = 1, hg = n; while (lw != hg) { int md = (lw + hg) / 2; if (chck(md)) hg = md; else lw = md + 1; } return rv_id[lw]; } void intl() { nm_ids = 0; for (int u = 1; u <= n; u++) { adj[u].clear(); id[u] = 0; } } int findEgg (int _n, vec<pii> _e) { intl(); n = _n; for (pii x : _e) adj[x.fir].push_back(x.sec), adj[x.sec].push_back(x.fir); dfs(); int ans = srch(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...