Submission #464808

# Submission time Handle Problem Language Result Execution time Memory
464808 2021-08-14T08:02:45 Z okaragul Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
23 ms 352 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int>> g;
vector<int> ord;

void dfs(int v, int p){
    ord.push_back(v);
    for(auto &ch:g[v]) if(ch!=p) dfs(ch, v);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    g.assign(N, vector<int>()); ord.clear();
    for(int i = 0; i < N-1; i++){
        auto &[a, b]=bridges[i];
        g[a-1].push_back(b-1);
        g[b-1].push_back(a-1);
    }
    dfs(0, -1);
    int l=1, r=N;
    while(l<r){
        int mid=(l+r)/2;
        
        vector<int> tmp;
        for(int i = 0; i < mid; i++) tmp.push_back(ord[i]+1);

        if(!query(tmp)) l=mid+1;
        else r=mid;
    }
    return ord[l-1]+1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 328 KB Number of queries: 8
2 Correct 13 ms 328 KB Number of queries: 9
3 Correct 19 ms 328 KB Number of queries: 9
4 Correct 20 ms 344 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 19 ms 352 KB Number of queries: 9
2 Correct 16 ms 328 KB Number of queries: 9
3 Correct 19 ms 328 KB Number of queries: 9
4 Correct 23 ms 328 KB Number of queries: 9