Submission #983650

# Submission time Handle Problem Language Result Execution time Memory
983650 2024-05-15T20:25:38 Z voidpoint11 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
14 ms 3752 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

typedef long long ll;

const int mxN = 1e5;

vector<int> g[mxN], ans;

void dfs(int u, int p) {
    ans.push_back(u);
    for (auto &v : g[u])
        if (v != p)
            dfs(v, u);
}

int findEgg(int n, vector<pair<int, int>> bridges) {
    for (int i = 1; i <= n; i++)    g[i].clear();
    for (pair<int, int> &i : bridges)
        g[i.first].push_back(i.second), g[i.second].push_back(i.first);
    dfs(1, 0);
    int l = 0, r = n - 2, m;
    while (l <= r) {
        m = (l + r) >> 1;
        if (query(vector<int>(ans.begin(), ans.begin() + m + 1)))   r = m - 1;
        else                                                        l = m + 1;
    }
    return ans[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2784 KB Number of queries: 4
2 Correct 1 ms 2788 KB Number of queries: 4
3 Correct 2 ms 2784 KB Number of queries: 4
4 Correct 1 ms 2784 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2808 KB Number of queries: 8
2 Correct 8 ms 3332 KB Number of queries: 9
3 Correct 13 ms 3500 KB Number of queries: 9
4 Correct 10 ms 3656 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 14 ms 3752 KB Number of queries: 9
2 Correct 10 ms 3072 KB Number of queries: 9
3 Correct 10 ms 3588 KB Number of queries: 9
4 Correct 11 ms 3376 KB Number of queries: 9