답안 #883847

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883847 2023-12-06T07:54:27 Z AndrijaM Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
11 ms 1000 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
 
vector<int>g[513];
vector<int>a;

void dfs(int node,int par)
{
    a.push_back(node);
    for(auto ax:g[node])
    {
        if(ax==par)continue;
        dfs(ax,node);
    }
}

int findEgg (int n, vector < pair < int, int > > b)
{
    for (int i = 1; i <= n; i++) g[i].clear();
	a.clear();
    for(auto ax:b)
    {
        g[ax.first].push_back(ax.second);
        g[ax.second].push_back(ax.first);
    }
    dfs(1,-1);
    int l=0;
    int r=n-1;
    while(l<r)
    {
        int mid=l+(r-l)/2;
        vector<int>v;
        for(int i=0;i<=mid;i++)
        {
            v.push_back(a[i]);
        }
        if(query(v)==1)
        {
            r=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    return a[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 0 ms 596 KB Number of queries: 4
3 Correct 0 ms 344 KB Number of queries: 4
4 Correct 0 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 728 KB Number of queries: 8
2 Correct 7 ms 728 KB Number of queries: 9
3 Correct 11 ms 740 KB Number of queries: 9
4 Correct 10 ms 744 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 768 KB Number of queries: 9
2 Correct 10 ms 1000 KB Number of queries: 9
3 Correct 10 ms 984 KB Number of queries: 9
4 Correct 10 ms 748 KB Number of queries: 9