Submission #835614

# Submission time Handle Problem Language Result Execution time Memory
835614 2023-08-23T16:39:18 Z VMaksimoski008 Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
2 ms 464 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int> > graph;
vector<int> euler;

void dfs(int u, int p) {
    euler.push_back(u);
    for(int &v : graph[u]) {
        if(v == p) continue;
        dfs(v, u);
    }
}

int findEgg(int n, vector<pair<int, int> > edges) {
    graph.clear();
    euler.clear();
    graph.resize(n+1);
    for(auto &x : edges) {
        graph[x.first].push_back(x.second);
        graph[x.second].push_back(x.first);
    }

    dfs(1, 0);
    int l=0, r=n-1;
    int ans = 0;

    while(l <= r) {
        int mid = (l + r) / 2; 
        vector<int> to_query(euler.begin(), euler.begin() + mid + 1);

        if(l == r) {
            ans = (l + r) / 2;
            break;
        }

        if(query(to_query)) {
            ans = mid;
            r = mid - 1;
        } else l = mid + 1;
    }

    return euler[ans];
}
# 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 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -