답안 #851977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851977 2023-09-21T02:53:11 Z AtabayRajabli Easter Eggs (info1cup17_eastereggs) C++11
100 / 100
12 ms 1228 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int>> g;
vector<int> order;

void dfs(int v, int prev)
{
    order.push_back(v);

    for(int i : g[v])
    {
        if(i == prev)continue;

        dfs(i, v);
    }
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
    g.clear();
    order.clear();

    g.resize(n+1);

    for(auto it : bridges)
    {
        int u = it.first, v = it.second;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    order.push_back(0);
    dfs(1, 0);

    int l = 1, r = n;
    while(l < r)
    {
        int mid = (l + r) / 2;

        if(query(vector<int> (order.begin()+1, order.begin() + 1 + mid)))
            r = mid;
        else
            l = mid + 1;
    }
    return order[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 0 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1228 KB Number of queries: 8
2 Correct 8 ms 736 KB Number of queries: 9
3 Correct 12 ms 988 KB Number of queries: 9
4 Correct 10 ms 736 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1012 KB Number of queries: 9
2 Correct 10 ms 504 KB Number of queries: 9
3 Correct 11 ms 496 KB Number of queries: 9
4 Correct 10 ms 744 KB Number of queries: 9