답안 #447295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447295 2021-07-25T21:19:18 Z Aryan_Raina Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
27 ms 364 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int findEgg (int N, vector < pair < int, int > > bridges)
{
    vector<int> g[N];
    for (auto [a, b] : bridges) {
        g[--a].push_back(--b);
        g[b].push_back(a);
    }

    vector<int> A;
    function<void(int,int)> dfs = [&](int u, int pu) {
        A.push_back(u+1);
        for (int v : g[u]) if (v != pu) dfs(v, u);
    };
    dfs(0,0);

    int lo = 0, hi = N-1;
    while (lo < hi) {
        int mid = (lo + hi)/2;
        if (query(vector<int>(A.begin(), A.begin()+mid+1))) hi = mid;
        else lo = mid+1;
    }

    return A[hi];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 340 KB Number of queries: 8
2 Correct 15 ms 332 KB Number of queries: 9
3 Correct 23 ms 328 KB Number of queries: 9
4 Correct 21 ms 348 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 364 KB Number of queries: 9
2 Correct 18 ms 336 KB Number of queries: 9
3 Correct 21 ms 340 KB Number of queries: 9
4 Correct 23 ms 328 KB Number of queries: 9