답안 #762145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762145 2023-06-21T01:24:57 Z kym Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 520 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)
{
    if(n==1){
        return 1;
    }
    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;

    }
    reset();
    return rev[hi];
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 520 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -