답안 #199174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
199174 2020-01-29T19:59:07 Z Bagritsevich_Stepan Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
35 ms 632 KB
#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
 
vector < int > q, g[10000];
 
void dfs(int v, int pr = -1){
    q.push_back(v);
    for(int to : g[v]){
        if(to != pr){
            dfs(to, v);
        }
    }
}
 
int findEgg(int N, vector < pair < int, int > > bridges){
    q.clear();
    for(int i = 1; i <= N; i++){
        g[i].clear();
    }
    for(auto it : bridges){
        g[it.first].push_back(it.second);
        g[it.second].push_back(it.first);
    }
    dfs(1);
    int l = 1, r = N;
    while(l < r){
        int mid = (r + l) >> 1;
        if(query(vector < int >(q.begin(), q.begin() + mid))){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return q[l - 1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Number of queries: 4
2 Correct 6 ms 504 KB Number of queries: 4
3 Correct 8 ms 504 KB Number of queries: 4
4 Correct 6 ms 504 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 632 KB Number of queries: 8
2 Correct 17 ms 504 KB Number of queries: 9
3 Correct 32 ms 504 KB Number of queries: 9
4 Correct 22 ms 632 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 492 KB Number of queries: 9
2 Correct 22 ms 504 KB Number of queries: 9
3 Correct 21 ms 632 KB Number of queries: 9
4 Correct 29 ms 504 KB Number of queries: 9