Submission #668000

# Submission time Handle Problem Language Result Execution time Memory
668000 2022-12-02T14:09:55 Z finn__ Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
2 ms 592 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

void get_preorder(vector<vector<int>> const &g, int u, int p, vector<int> &trav)
{
    trav.push_back(u + 1);

    for (int const &v : g[u])
        if (v != p)
            get_preorder(g, v, u, trav);
}

int findEgg(int n, vector<pair<int, int>> edges)
{
    vector<vector<int>> g(n);
    for (auto const &[u, v] : edges)
    {
        g[u - 1].push_back(v - 1);
        g[v - 1].push_back(u - 1);
    }

    vector<int> preorder;
    get_preorder(g, 0, -1, preorder);

    size_t a = 0, b = n;
    while (a < b)
    {
        size_t mid = (a + b) / 2;
        if (query(vector<int>(preorder.begin(), preorder.begin() + mid)))
            b = mid;
        else
            a = mid + 1;
    }

    return preorder[a];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -