Submission #827772

# Submission time Handle Problem Language Result Execution time Memory
827772 2023-08-16T18:12:10 Z PanosPask Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 464 KB
#include <bits/stdc++.h>
#include "grader.h"

#define pb push_back

using namespace std;

vector<vector<int>> adj_list;

vector<int> dfs_order;

void dfs(int node, int par)
{
    dfs_order.pb(node);

    for (auto neigh : adj_list[node])
        if (neigh != par)
            dfs(neigh, node);
}

bool query(int i)
{
    vector<int> v;
    for (int j = 0; j <= i; j++)
        v.pb(dfs_order[j]);

    return query(v);
}

int findEgg(int N, vector<pair<int, int>> bridges)
{
    adj_list.resize(N);

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

    dfs(0, -1);

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

    while (r > l + 1) {
        int mid = (l + r) / 2;
        if (query(mid))
            r = mid;
        else
            l = mid;
    }

    return r;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -