답안 #384478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
384478 2021-04-01T17:47:22 Z ak2006 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
24 ms 492 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

#define pb push_back
using vi = vector<int>;
using vvi = vector<vi>;
vvi adj(513);
vi a;
void dfs(int i,int p)
{
    a.pb(i);
    for (int c:adj[i]){
        if (c != p)
            dfs(c,i);
    }
}
int findEgg(int n,vector<pair<int,int>>b)
{
    for (int i = 0;i<=512;i++)adj[i].clear();
    a.clear();
    for (pair<int,int> i : b)adj[i.first].pb(i.second),adj[i.second].pb(i.first);
    dfs(1,1);
    int l = 0,r = n - 1;
    while (l < r){
        int mid = (l + r + 1)/2;
        if (query(vector<int>(a.begin(),a.begin() + mid))){
            r = mid - 1;
        }
        else l = mid;
    }
    return a[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 364 KB Number of queries: 4
2 Correct 2 ms 364 KB Number of queries: 4
3 Correct 1 ms 364 KB Number of queries: 4
4 Correct 2 ms 364 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 364 KB Number of queries: 8
2 Correct 13 ms 364 KB Number of queries: 9
3 Correct 22 ms 364 KB Number of queries: 9
4 Correct 18 ms 492 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 384 KB Number of queries: 9
2 Correct 17 ms 428 KB Number of queries: 9
3 Correct 24 ms 364 KB Number of queries: 9
4 Correct 24 ms 364 KB Number of queries: 9