답안 #484566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484566 2021-11-04T12:05:09 Z MohamedFaresNebili Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
18 ms 356 KB
#include <bits/stdc++.h>
#include "grader.h"
 
        using namespace std;
 
        vector<int>adj[555], id;
        void dfs(int v = 1, int p = 0) {
            id.push_back(v);
            for(auto u: adj[v]) { 
                if(u == p) continue;
                dfs(u, v);
            }
        }
 
        int findEgg (int N, vector < pair < int, int > > bridges)
        {
            for(int l = 1; l <= N; l++) adj[l].clear();
            id.clear();
            for(auto u : bridges) {
                int a = u.first, b = u.second;
                adj[a].push_back(b); adj[b].push_back(a);
            }
            dfs();
            int lo = 0, hi = N - 1;
            while(lo != hi) {
                int md = (lo + hi + 1)/2;
                if(query(vector<int>(id.begin(), id.begin() + md))) hi = md - 1;
                else lo = md;
            }
            return id[lo];
        }
# 결과 실행 시간 메모리 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 3 ms 328 KB Number of queries: 8
2 Correct 10 ms 336 KB Number of queries: 9
3 Correct 14 ms 336 KB Number of queries: 9
4 Correct 12 ms 328 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 356 KB Number of queries: 9
2 Correct 13 ms 336 KB Number of queries: 9
3 Correct 18 ms 336 KB Number of queries: 9
4 Correct 14 ms 336 KB Number of queries: 9