답안 #98257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98257 2019-02-21T17:23:32 Z Vasiljko Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
12 ms 760 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=0;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 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Number of queries: 9
2 Runtime error 4 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -