제출 #1127075

#제출 시각아이디문제언어결과실행 시간메모리
1127075gygEaster Eggs (info1cup17_eastereggs)C++20
0 / 100
0 ms480 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; void dfs(int u = 1) { id[u] = ++nm_ids; 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(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; } for (int u = 1; u <= n; u++) if (id[u] == lw) return u; assert(false); return -1; } 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...