Submission #860105

# Submission time Handle Problem Language Result Execution time Memory
860105 2023-10-11T16:22:27 Z Nonoze Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
14 ms 1496 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<int> vec;
vector<bool> visited(520, false);
vector<int> adj[520];

void dfs(int s) {
    if (visited[s]) return;
    vec.push_back(s);
    visited[s]=true;
    for (auto u: adj[s]) dfs(u);
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    vec.clear();
    for (int i=0; i<=N; i++) adj[i].clear(), visited[i]=false;
    for (auto u: bridges) {
        adj[u.first].push_back(u.second);
        adj[u.second].push_back(u.first);
    }
    dfs(1);
    int l=0, r=N-1;
    while (l<r) {
        int mid=l+(r-l)/2;
        if (query(vector<int>(vec.begin(), vec.begin()+mid+1))) {
            r=mid;
        } else {
            l=mid+1;
        }
    }
    return vec[l];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Number of queries: 4
2 Correct 0 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 480 KB Number of queries: 8
2 Correct 8 ms 736 KB Number of queries: 9
3 Correct 11 ms 732 KB Number of queries: 9
4 Correct 10 ms 856 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 14 ms 760 KB Number of queries: 9
2 Correct 9 ms 732 KB Number of queries: 9
3 Correct 10 ms 1496 KB Number of queries: 9
4 Correct 10 ms 736 KB Number of queries: 9