Submission #98259

# Submission time Handle Problem Language Result Execution time Memory
98259 2019-02-21T17:25:36 Z Vasiljko Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
33 ms 440 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-2;
    ans=-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;
        }
    }
    if(ans==-1)ans=n-1;

    return seq[ans];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Number of queries: 4
2 Correct 3 ms 336 KB Number of queries: 4
3 Correct 3 ms 256 KB Number of queries: 4
4 Correct 3 ms 256 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 412 KB Number of queries: 8
2 Correct 16 ms 440 KB Number of queries: 9
3 Correct 19 ms 256 KB Number of queries: 9
4 Correct 24 ms 256 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 33 ms 284 KB Number of queries: 9
2 Correct 15 ms 368 KB Number of queries: 9
3 Correct 25 ms 256 KB Number of queries: 9
4 Correct 25 ms 256 KB Number of queries: 9