Submission #874293

# Submission time Handle Problem Language Result Execution time Memory
874293 2023-11-16T16:01:19 Z asli_bg Easter Eggs (info1cup17_eastereggs) C++11
100 / 100
11 ms 1240 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<int> ord;
vector<int> adjlist[550];

void dfs(int i=1, int r=0){
    ord.push_back(i);
    for(auto komsu:adjlist[i]){
        if(komsu!=r){
            dfs(komsu,i);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{

    for(int i=1;i<=N;i++){
        adjlist[i].clear();
    }

    ord.clear();

    for(auto el:bridges){
        int a=el.first;
        int b=el.second;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }

    dfs();

    int l=0;
    int r=N-1;

    while(l<r){
        int mid=(l+r+1)/2;
        if(query(vector<int>(ord.begin(),ord.begin()+mid))) r=mid-1;
        else l=mid; 
    }

    return ord[l];
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Number of queries: 4
2 Correct 0 ms 344 KB Number of queries: 4
3 Correct 0 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 984 KB Number of queries: 8
2 Correct 7 ms 1240 KB Number of queries: 9
3 Correct 10 ms 480 KB Number of queries: 9
4 Correct 9 ms 736 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1004 KB Number of queries: 9
2 Correct 9 ms 476 KB Number of queries: 9
3 Correct 10 ms 732 KB Number of queries: 9
4 Correct 9 ms 752 KB Number of queries: 9