답안 #419995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
419995 2021-06-07T21:19:29 Z Runtime_error_ Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
21 ms 472 KB
#include <bits/stdc++.h>
#include "grader.h"
#define pb push_back
using namespace std;
const int inf = 1e3+9;

vector<int> DfsOrder,adj[inf];

void dfs(int u,int p){
    DfsOrder.pb(u);
    for(auto v:adj[u])
        if(v != p)
            dfs(v,u);
}

int findEgg (int n, vector < pair < int, int > > bridges)
{
    for(int i=1;i<=n;i++)
        adj[i].clear();
    DfsOrder.clear();
    for(auto o:bridges)
        adj[o.first].pb(o.second),
        adj[o.second].pb(o.first);

    dfs(1,-1);
    int l = 0,r = n-1;
    while(r!=l){
        int mid = (l+r)/2;
        if(query(vector<int>(DfsOrder.begin(),DfsOrder.begin()+mid+1)))
            r = mid;
        else
            l = mid+1;
    }
    return DfsOrder[l];
}
# 결과 실행 시간 메모리 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 Correct 6 ms 472 KB Number of queries: 8
2 Correct 17 ms 460 KB Number of queries: 9
3 Correct 19 ms 356 KB Number of queries: 9
4 Correct 16 ms 360 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 328 KB Number of queries: 9
2 Correct 18 ms 352 KB Number of queries: 9
3 Correct 21 ms 356 KB Number of queries: 9
4 Correct 19 ms 328 KB Number of queries: 9