Submission #915168

# Submission time Handle Problem Language Result Execution time Memory
915168 2024-01-23T12:32:53 Z Pikachu Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
12 ms 1244 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int maxn = 520, oo = 1e9;
int n;
vector<int> adj[maxn];
vector<int> pos;

int findEgg (int N, vector<pair<int,int> > bridges)
{
    ::n = N;
    pos.clear();
    for (int i = 1; i <= n; i++) adj[i].clear();
    for (pair<int,int> p : bridges) {
        adj[p.first].push_back(p.second);
        adj[p.second].push_back(p.first);
    }

    auto DFS = [&] (auto DFS, int u, int par) -> void {
        pos.push_back(u);
        for (int v : adj[u]) {
            if (v == par) continue;
            DFS(DFS, v, u);
        }
    };

    DFS(DFS, 1, -1);

    int l = 0, r = n - 1;
    while (l < r) {
        int mid = (l + r) >> 1;
        if (query(vector<int>(pos.begin(), pos.begin() + mid + 1))) {
            r = mid;
        }
        else l = mid + 1;
    }
    
    return pos[r];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 972 KB Number of queries: 8
2 Correct 7 ms 728 KB Number of queries: 9
3 Correct 12 ms 488 KB Number of queries: 9
4 Correct 10 ms 1244 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 12 ms 744 KB Number of queries: 9
2 Correct 10 ms 996 KB Number of queries: 9
3 Correct 11 ms 724 KB Number of queries: 9
4 Correct 10 ms 860 KB Number of queries: 9