Submission #835609

# Submission time Handle Problem Language Result Execution time Memory
835609 2023-08-23T16:37:23 Z VMaksimoski008 Easter Eggs (info1cup17_eastereggs) C++14
87 / 100
19 ms 460 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(query(to_query)) {
            ans = mid;
            r = mid - 1;
        } else l = mid + 1;
    }

    return euler[ans];
}
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 208 KB Number of queries: 5
2 Partially correct 1 ms 208 KB Number of queries: 5
3 Partially correct 1 ms 208 KB Number of queries: 5
4 Partially correct 1 ms 332 KB Number of queries: 5
# Verdict Execution time Memory Grader output
1 Correct 6 ms 336 KB Number of queries: 9
2 Correct 9 ms 360 KB Number of queries: 9
3 Correct 15 ms 348 KB Number of queries: 9
4 Correct 12 ms 372 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Partially correct 19 ms 336 KB Number of queries: 10
2 Correct 11 ms 336 KB Number of queries: 9
3 Partially correct 14 ms 460 KB Number of queries: 10
4 Partially correct 13 ms 336 KB Number of queries: 10