Submission #1029640

# Submission time Handle Problem Language Result Execution time Memory
1029640 2024-07-21T06:56:13 Z coolboy19521 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
11 ms 600 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int sz = 600;

vector<int> aj[sz];
vector<int> pt;

void dfs(int v, int p = -1) {
    pt.push_back(v);
    for (int u : aj[v]) if (u != p)
        dfs(u, v);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for (int i = 1; i <= N; i ++)
        aj[i].clear();

    pt.clear();

    for (auto& [v, u] : bridges) {
        aj[v].push_back(u);
        aj[u].push_back(v);
    }

    dfs(1);

    int le = 0, ri = N - 1;
    int r;

    while (ri != le) {
        int mi = (le + ri + 1) / 2;
        r = query(vector<int>(pt.begin(), pt.begin() + mi));
        if (r) ri = mi - 1;
        else le = mi;
    }

    return pt[le];
}
# 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 4 ms 344 KB Number of queries: 8
2 Correct 9 ms 492 KB Number of queries: 9
3 Correct 11 ms 600 KB Number of queries: 9
4 Correct 8 ms 600 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 10 ms 520 KB Number of queries: 9
2 Correct 6 ms 344 KB Number of queries: 9
3 Correct 8 ms 344 KB Number of queries: 9
4 Correct 8 ms 492 KB Number of queries: 9