Submission #762143

# Submission time Handle Problem Language Result Execution time Memory
762143 2023-06-21T01:23:28 Z kym Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 592 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 515;
const int inf=1234567890;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> adj[MAXN];
int n;
int pre[MAXN];
int cnt=1;
int rev[MAXN];
void reset(){
    for(int i=0;i<=n;i++)adj[i].clear();
    cnt=1;
    memset(pre,0,sizeof pre);
    memset(rev,0,sizeof rev);
}
void dfs(int x, int p){
    pre[x]=cnt;
    rev[cnt]=x;
    cnt++;
    for(auto v:adj[x])if(v!=p){
        dfs(v,x);
    }
}
bool check(int l){
    vector<int> vec;
    for(int i=1;i<=l;i++){
        vec.push_back(rev[i]);
    }
    bool r=query(vec);
    return r;
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    n=N;
    for(auto x:bridges){
        adj[x.first].push_back(x.second);
        adj[x.second].push_back(x.first);
    }
    dfs(1,-1);
    int lo=0,hi=n+1;
    while(lo<hi-1){
        int mid=(lo+hi)/2;
        if(check(mid))hi=mid;
        else lo=mid;

    }
    return rev[hi];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -