# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
676692 | 2022-12-31T17:52:38 Z | LucaLucaM | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; vector<int>v[513]; vector<int>order; void dfs (int x, int par) { order.push_back(x); for (int i : v[x]) { if (i == par) continue; dfs(i, x); } } int findEgg(int N, vector < pair < int, int > > bridges) { for (pair<int, int>p : bridges) { v[p.first].push_back(p.second); v[p.second].push_back(p.first); } dfs(1, -1); int l=1, r=N; while (l < r) { int mid = (l + r) / 2; vector<int>curr; for (int i=0; i<mid; i++) curr.push_back(order[i]); if (query(curr)) r = mid; else l = mid + 1; } return order[r-1]; }