Submission #851961

# Submission time Handle Problem Language Result Execution time Memory
851961 2023-09-21T02:18:54 Z AtabayRajabli Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
400 ms 131072 KB
#include <bits/stdc++.h>

using namespace std;

void dfs(int v, int prev, vector<int> &order, vector<vector<int>> &g)
{
    order.push_back(v);

    for(int i : g[v])
    {
        if(i == prev)continue;

        dfs(i, v, order, g);
    }
}

int query(vector < int > islands);

int findEgg(int n, vector<pair<int, int>> bridges)
{
    vector<vector<int>> g(n+1, vector<int>(n+1));
    vector<int> order;

    for(auto &[u, v] : bridges)
    {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1, 0, order, g);

    int l = 0, r = 0;
    while(l <= r)
    {
        int mid = (l + r) >> 1;

        if(query(vector<int> (order.begin(), order.begin() + mid)))
            r = mid;
        else
            l = mid + 1;
    }
    return order[l];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 492 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2914 ms 131072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 70532 KB Time limit exceeded
2 Halted 0 ms 0 KB -