답안 #522732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522732 2022-02-05T15:01:32 Z Theo830 Easter Eggs (info1cup17_eastereggs) C++17
40 / 100
1 ms 456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "grader.h"
vector<vector<ll> >adj;
ll arr[600];
ll tim = 0;
void dfs(ll idx,ll p){
    arr[tim] = idx;
    tim++;
    for(auto x:adj[idx]){
        if(x != p){
            dfs(x,idx);
        }
    }
}
int findEgg(int N, vector < pair < int, int > > bridges){
    adj.assign(N+5,vector<ll>());
    for(auto x:bridges){
        adj[x.F].pb(x.S);
        adj[x.S].pb(x.F);
    }
    dfs(1,0);
    ll l = 0,r = N-1;
    ll ans = r;
    while(l <= r){
        ll mid = (l+r)/2;
        vector<int>exo;
        if(l == ans){
            break;
        }
        f(i,0,mid + 1){
            exo.pb(arr[i]);
        }
        if(query(exo)){
            r = mid - 1;
            ans = min(ans,mid);
        }
        else{
            l = mid + 1;
        }
    }
    return arr[ans];
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 1 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 452 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -