# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
412764 | 2021-05-27T13:19:39 Z | aris12345678 | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; const int mxN = 515; vector<int> adj[mxN]; int euler[mxN]; void dfs(int u, int p, int cnt = 0) { euler[cnt++] = u; for(auto &v : adj[u]) { if(v == p) continue; dfs(v, u); } } int findEgg(int n, vector<pair<int, int> > bridges) { for(int i = 1; i <= n; i++) adj[i].clear(); for(int i = 1; i < n; i++) { adj[bridge[i].first].push_back(bridge[i].second); adj[bridge[i].second].push_back(bridge[i].first); } dfs(1, 0); int st = 1, en = n, md, ans; while(st <= en) { md = (st+en)/2; vector<int> check; for(int i = st; i <= md; i++) check.push_back(euler[i]); if(query(check)) { en = md-1; ans = md; } else { st = md+1; } } return ans; }