Submission #860060

# Submission time Handle Problem Language Result Execution time Memory
860060 2023-10-11T13:30:50 Z Nonoze Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
1 ms 496 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();
    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;
    int ans=0;
    while (l<=r) {
        int mid=l+(r-l)/2;
        if (query(vector<int>(vec.begin(), vec.begin()+mid))) {
            ans=mid;
            r=mid-1;
        } else {
            l=mid+1;
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -