Submission #964497

# Submission time Handle Problem Language Result Execution time Memory
964497 2024-04-17T02:58:08 Z bachhoangxuan Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
14 ms 1024 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

int findEgg (int N, vector <pair<int,int>> bridges)
{
    vector<vector<int>> edge(N+1);
    for(auto [u,v]:bridges){
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    vector<int> path;
    function<void(int,int)> dfs = [&](int u,int p){
        path.push_back(u);
        for(int v:edge[u]) if(v!=p) dfs(v,u);
    };
    dfs(1,0);
    int l=0,r=N-1;
    while(l<r){
        int mid=(l+r)>>1;
        if(query(vector<int>(path.begin(),path.begin()+mid+1))) r=mid;
        else l=mid+1;
    }
    return path[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 980 KB Number of queries: 8
2 Correct 9 ms 980 KB Number of queries: 9
3 Correct 13 ms 984 KB Number of queries: 9
4 Correct 12 ms 736 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1024 KB Number of queries: 9
2 Correct 12 ms 744 KB Number of queries: 9
3 Correct 13 ms 708 KB Number of queries: 9
4 Correct 13 ms 644 KB Number of queries: 9