답안 #918417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918417 2024-01-29T19:47:11 Z vjudge1 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
14 ms 1748 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll long long
using namespace std;
const ll sz=600;
ll used[sz];
vector<ll>g[sz], vec;
void dfs(ll u)
{
    vec.push_back(u);
    used[u]=1;
    for(auto v:g[u]){
        if(!used[v]){
            dfs(v);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > br)
{
    /*
    if (query ({1})) return 1;
    return N;*/
    for(auto i:br){
        ll u=i.first;
        ll v=i.second;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1);
    ll l=0, r=N-1;
    while(l<r){
        ll mid=(l+r)/2;
        vector<int>cur;
        for(int i=0; i<=mid; i++){
            cur.push_back(vec[i]);
        }
        int q=query(cur);
        if(q==1){
            r=mid;
        }
        else{
            l=mid+1;
        }
    }
    return vec[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Number of queries: 4
2 Correct 1 ms 452 KB Number of queries: 4
3 Correct 1 ms 700 KB Number of queries: 4
4 Correct 1 ms 460 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1244 KB Number of queries: 8
2 Correct 8 ms 1256 KB Number of queries: 9
3 Correct 11 ms 1748 KB Number of queries: 9
4 Correct 10 ms 1172 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1252 KB Number of queries: 9
2 Correct 10 ms 1260 KB Number of queries: 9
3 Correct 10 ms 1048 KB Number of queries: 9
4 Correct 11 ms 1484 KB Number of queries: 9