Submission #575419

# Submission time Handle Problem Language Result Execution time Memory
575419 2022-06-10T11:20:14 Z spensa Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
17 ms 356 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define pb push_back

vector<int> G[515];
vector<int> arr;

void dfs(int a, int b){
    // cout<<"a="<<a<<" ";
    arr.pb(a);
    for(auto k: G[a]){
        if(k==b) continue;
        dfs(k,a);
    }
}

int findEgg(int N, vector<pair<int,int>> bridges){
    for(int i=1; i<=N; i++) G[i].clear();
    arr.clear();

    for(auto k:bridges){
        G[k.first].pb(k.second);
        G[k.second].pb(k.first);
    }

    dfs(1, 0);

    // for(int i=0; i<N; i++){
    //     cout<<arr[i]<<" ";
    // }

    int l=0, r=N-1, mid;
    while(l!=r){
        mid = l + (r-l)/2;
        // cout<<mid<<" ";
        if(query(vector<int>(arr.begin(), arr.begin()+mid+1))){
            r = mid;
        }
        else l = mid+1;
    }

    return arr[l];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 4 ms 336 KB Number of queries: 8
2 Correct 10 ms 356 KB Number of queries: 9
3 Correct 17 ms 336 KB Number of queries: 9
4 Correct 17 ms 336 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 17 ms 336 KB Number of queries: 9
2 Correct 14 ms 344 KB Number of queries: 9
3 Correct 16 ms 336 KB Number of queries: 9
4 Correct 13 ms 348 KB Number of queries: 9