# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
744194 | 2023-05-18T09:05:26 Z | rahidilbayramli | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KB |
#include "grader.h" #include<bits/stdc++.h> #define ll long long #define ld long double #define vl vector<ll> #define vi vector<int> #define pb push_back #define f first #define s second #define pii pair<int, int> #define pll pair<ll, ll> using namespace std; vector<int>graph[513], ord; void dfs(int node = 1, int par = 0) { ord.pb(node); for(int i : graph[node]) { if(i != par) dfs(i, node); } } int findEgg(int N, vector<pair<int, int>> bridges) { for(i = 1; i <= N; i++) graph[i].clear(); ord.clear(); for(pii x : bridges){ graph[i.f].pb(i.s); graph[i.s].pb(i.f); } dfs(); int l = 0, r = N - 1; while(l != r) { int mid = (l + r + 1) / 2; if(query(vi(ord.begin(), ord.begin() + mid))) r = mid - 1; else l = mid; } return ord[l]; }