Submission #1053958

# Submission time Handle Problem Language Result Execution time Memory
1053958 2024-08-11T23:43:26 Z SulA Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
131 ms 131072 KB
#include <iostream>
#include <set>
#include "grader.h"

using namespace std;

vector<int> adj[513], preorder;

void dfs(int u = 1, int p = 0) {
    preorder.push_back(u);
    for (int ch : adj[u]) if (ch != p) dfs(ch, u);
}

int findEgg (int n, vector<pair<int,int>> bridges) {
    for (auto [u, v] : bridges) {
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs();
    int l = 0, r = n-1;
    while (r > l) {
        int mid = (l+r)/2;
        vector<int> myquery{};
        for (int i = 0; i <= mid; i++) myquery.push_back(preorder[i]);
        bool res = query(myquery) == 1;
        //cout << "MY QUERY IS ";
        //for (int u : myquery) cout << u << " ";
        //cout << '\n';
        if (res) r = mid;
        else l = mid+1;
    }
    return preorder[l];
}
# Verdict Execution time Memory Grader output
1 Runtime error 131 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 104 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -