답안 #918058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918058 2024-01-29T12:59:07 Z aykhn Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
13 ms 1256 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

vector<int> e;
vector<int> adj[600];

void dfs(int a, int p)
{
    e.push_back(a);
    for (int v : adj[a])
    {
        if (v == p) continue;
        dfs(v, a);
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
  e.clear();
    for (int i = 0; i <= N; i++) adj[i].clear();
    for (pair<int, int> p : bridges)
    {
        adj[p.first].push_back(p.second);
        adj[p.second].push_back(p.first);
    }
    dfs(1, 1);
    int l = 0;
    int r = e.size() - 1;
    while (l < r)
    {
        int mid = (l + r) >> 1;
        vector<int> nw;
        for (int i = 0; i <= mid; i++) nw.push_back(e[i]);
        if (query(nw)) r = mid;
        else l = mid + 1;
    }
    return e[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 732 KB Number of queries: 8
2 Correct 8 ms 1244 KB Number of queries: 9
3 Correct 11 ms 744 KB Number of queries: 9
4 Correct 11 ms 1256 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 764 KB Number of queries: 9
2 Correct 10 ms 1008 KB Number of queries: 9
3 Correct 10 ms 732 KB Number of queries: 9
4 Correct 12 ms 748 KB Number of queries: 9