답안 #762147

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

    }
   
    int ans=rev[hi];
    reset();
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 208 KB Number of queries: 5
2 Partially correct 1 ms 208 KB Number of queries: 5
3 Partially correct 1 ms 208 KB Number of queries: 5
4 Partially correct 1 ms 208 KB Number of queries: 5
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 336 KB Number of queries: 9
2 Correct 8 ms 360 KB Number of queries: 9
3 Correct 11 ms 336 KB Number of queries: 9
4 Correct 12 ms 336 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Partially correct 10 ms 384 KB Number of queries: 10
2 Correct 11 ms 368 KB Number of queries: 9
3 Partially correct 12 ms 352 KB Number of queries: 10
4 Partially correct 12 ms 360 KB Number of queries: 10