제출 #288348

#제출 시각아이디문제언어결과실행 시간메모리
288348andreiomdEaster Eggs (info1cup17_eastereggs)C++11
0 / 100
1 ms640 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; typedef pair < int, int > PII; const int NMAX = ((1 << 9) + 5); const int ROOT = 1; int N, M; vector < int > G[NMAX]; bool Sel[NMAX]; int V[(NMAX << 1)], cnt; inline void Add_Edge (int X, int Y) { G[X].push_back(Y), G[Y].push_back(X); return; } inline void DFS (int Node) { Sel[Node] = 1; V[++cnt] = Node; for(auto it : G[Node]) if(!Sel[it]) { DFS(it); V[++cnt] = Node; } return; } inline void Precalculation () { DFS(ROOT); return; } inline bool Ok (int pos) { bitset < NMAX > mp; vector < int > q; for(int i = 1; i <= pos; ++i) if(!mp[V[i]]) q.push_back(V[i]); else mp[V[i]] = 1; return query(q); } inline int Solve () { int Left = 1, Right = cnt; while(Left < Right) { int Mid = (Left + Right) >> 1; if(Ok(Mid)) Right = Mid; else Left = Mid + 1; } return V[Left]; } int findEgg (int n, vector < PII > edges) { ++M; if(M == 1) { N = n; for(auto it : edges) Add_Edge(it.first, it.second); Precalculation(); } return Solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...