Submission #766239

# Submission time Handle Problem Language Result Execution time Memory
766239 2023-06-25T11:59:26 Z Ahmed57 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
16 ms 360 KB
#include "grader.h"

#include <bits/stdc++.h>

using namespace std;
int findEgg(int N, vector < pair < int, int > > bridges){
    queue<int> q;
    vector<int> adj[N+1];
    for(auto i:bridges){
        adj[i.first].push_back(i.second);
        adj[i.second].push_back(i.first);
    }
    q.push(1);
    int vis[N+1] = {0};
    vis[1] = 1;
    vector<int> lol;
    while(!q.empty()){
        int x= q.front();
        lol.push_back(x);
        q.pop();
        for(auto j:adj[x]){
            if(!vis[j]){
                q.push(j);vis[j] = 1;
            }
        }
    }
    int l = 1 , r = N-1 , ans = lol[N-1];
    while(l<=r){
        int mid = (l+r)/2;
        vector<int> xd;
        for(int i =0;i<mid;i++){
            xd.push_back(lol[i]);
        }
        if(query(xd)){
            ans = lol[mid-1];
            r = mid-1;
        }else l = mid+1;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 5 ms 336 KB Number of queries: 8
2 Correct 11 ms 344 KB Number of queries: 9
3 Correct 16 ms 336 KB Number of queries: 9
4 Correct 15 ms 360 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 16 ms 336 KB Number of queries: 9
2 Correct 13 ms 276 KB Number of queries: 9
3 Correct 13 ms 336 KB Number of queries: 9
4 Correct 14 ms 352 KB Number of queries: 9