답안 #98258

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98258 2019-02-21T17:24:49 Z Vasiljko Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
25 ms 384 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

typedef long long ll;
const ll MOD = 1e9+7;

int n,cnt,ans;
vector<int>v[550],seq;

void dfs(int s,int p){
    seq.push_back(s);
    for(auto e:v[s])if(e!=p)dfs(e,s);
}

int findEgg(int N,vector<pair<int,int> >b){
    n=N;
    for(int i=1;i<=n;i++)v[i].clear();
    for(auto e:b){
        v[e.first].push_back(e.second);
        v[e.second].push_back(e.first);
    }
    seq.clear();
    dfs(1,0);

    int l=0;
    int r=n-1;
    vector<int>q;

    while(l<=r){
        int mid=(l+r)>>1;
        q.clear();
        for(int i=0;i<=mid;i++)q.push_back(seq[i]);
        if(query(q)){
            r=mid-1;
            ans=mid;
        }else{
            l=mid+1;
        }
    }


    return seq[ans];
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Number of queries: 5
2 Incorrect 3 ms 384 KB Number of queries: 5
3 Incorrect 4 ms 256 KB Number of queries: 5
4 Incorrect 3 ms 256 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 256 KB Number of queries: 9
2 Correct 17 ms 384 KB Number of queries: 9
3 Correct 25 ms 384 KB Number of queries: 9
4 Correct 17 ms 256 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 384 KB Number of queries: 10
2 Correct 16 ms 384 KB Number of queries: 9
3 Incorrect 22 ms 384 KB Number of queries: 10
4 Incorrect 19 ms 256 KB Number of queries: 10