답안 #61620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61620 2018-07-26T08:15:40 Z Megumi_Tadokoro Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
37 ms 700 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

const int N = 515;
vector <int> g[N], vertices, islands;

void dfs (int u, int p) {
    vertices.push_back(u);
    for (int v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
    }
}

int findEgg(int N, vector<pair<int, int> > bridges) {
    int L = 1, R = N;
    for (int i = 1; i <= N; i++) g[i].clear();
    for (auto i: bridges) {
        g[i.first].push_back(i.second);
        g[i.second].push_back(i.first);
    }
    vertices.clear();

    dfs(1, 1);

    while(L < R) {
        int M = (L + R)/2;
        islands.clear();
        for (int i = 1; i <= M; i++) islands.push_back(vertices[i - 1]);

        if(query(islands)) R = M;
        else L = M+1;
    }

    return vertices[R - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Number of queries: 4
2 Correct 3 ms 436 KB Number of queries: 4
3 Correct 4 ms 496 KB Number of queries: 4
4 Correct 4 ms 496 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 504 KB Number of queries: 8
2 Correct 14 ms 504 KB Number of queries: 9
3 Correct 32 ms 544 KB Number of queries: 9
4 Correct 31 ms 544 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 672 KB Number of queries: 9
2 Correct 30 ms 676 KB Number of queries: 9
3 Correct 37 ms 700 KB Number of queries: 9
4 Correct 24 ms 700 KB Number of queries: 9