# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
890561 | 2023-12-21T13:19:16 Z | Iwantbemaster | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; int i, cur[1005]; vector<int> result[1005]; void DFS(int res, int ans){ cur[++i] = res; for(auto to : result[res]){ if(to == ans) continue; DFS(to, res); } } int Query(int res){ vector<int> v; for(int i = 1; i <= res; i++) v.push_back(ord[i]); return query(v); } int findEgg(int n, vector<pair<int, int>> bridges){ for(int i = 1; i <= N; i++) result[i].clear(); for(auto e: bridges){ result[e.first].push_back(e.second); result[e.second].push_back(e.first); } i = 0; DFS(1, 0); int l = 1, r = N; while(l < r){ int m = l + (r - l) / 2; if(Query(m)) r = m; else l = m + 1; } return cur[l]; }