Submission #1035471

# Submission time Handle Problem Language Result Execution time Memory
1035471 2024-07-26T11:24:17 Z TsotneSV Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
14 ms 604 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
/* /\_/\
  (= ._.)
  / >  \>
*/

#define pb push_back

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

    vector<vector<int>> g(N + 1); vector<int> tour;

    for(int i=0;i<N-1;i++) {
    	int u = bridges[i].first,v = bridges[i].second;
        g[u].pb(v);
        g[v].pb(u);
    }

    function<void(int,int)> dfs = [&](int v,int p) {

        tour.pb(v);

        for(int i : g[v]) {
            if(i == p) continue;
            dfs(i,v);
        }

    };

    dfs(1,0);

    int l = 0,r = N-1;

    while(l < r) {
        int mid = (l + r)/2; vector<int> islands;

        for(int i=0;i<=mid;i++) {
            islands.pb(tour[i]);
        }

        if(query(islands)) {
            r = mid;
        }else {
            l = mid + 1;
        }
    }

    return tour[r];

}
# 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 368 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 7 ms 344 KB Number of queries: 8
2 Correct 7 ms 344 KB Number of queries: 9
3 Correct 11 ms 344 KB Number of queries: 9
4 Correct 11 ms 344 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 532 KB Number of queries: 9
2 Correct 14 ms 604 KB Number of queries: 9
3 Correct 10 ms 344 KB Number of queries: 9
4 Correct 10 ms 604 KB Number of queries: 9