Submission #676696

# Submission time Handle Problem Language Result Execution time Memory
676696 2022-12-31T17:55:43 Z LucaLucaM Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
21 ms 368 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<int>v[513];
vector<int>order;

void dfs (int x, int par)
{
    order.push_back(x);
    for (int i : v[x])
    {
        if (i == par)
            continue;
        dfs(i, x);
    }
}

int findEgg(int N, vector < pair < int, int > > bridges)
{
    for (pair<int, int>p : bridges)
    {
        v[p.first].push_back(p.second);
        v[p.second].push_back(p.first);
    }

    dfs(1, -1);

    int l=1, r=N;
    while (l < r)
    {
        int mid = (l + r) / 2;

        vector<int>curr;
        for (int i=0; i<mid; i++)
            curr.push_back(order[i]);

        if (query(curr))
            r = mid;
        else
            l = mid + 1;
    }
    
    int ret = order[r-1];
    for (int i=1; i<=N; i++)
        v[i].clear();
    order.clear();
    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 1 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 336 KB Number of queries: 8
2 Correct 13 ms 348 KB Number of queries: 9
3 Correct 14 ms 340 KB Number of queries: 9
4 Correct 13 ms 356 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 21 ms 368 KB Number of queries: 9
2 Correct 13 ms 336 KB Number of queries: 9
3 Correct 16 ms 360 KB Number of queries: 9
4 Correct 16 ms 360 KB Number of queries: 9