답안 #867719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867719 2023-10-29T10:08:52 Z ElenaBM Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
13 ms 1240 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
void dfs (int act, vector<vector<int>>& adj, vector<int>&li, int ant){
    li.push_back(act);
    for (int conex = 0; conex < (int)adj[act].size(); ++conex){
        if (adj[act][conex] != ant) dfs(adj[act][conex], adj, li, act);
    }
}

int findEgg (int N, vector<pair<int,int>>bridges){
    vector<vector<int>> adj(N, vector<int>());
    for (int i = 0; i < (int)bridges.size(); ++i){
        adj[bridges[i].first - 1].push_back(bridges[i].second - 1);
        adj[bridges[i].second - 1].push_back(bridges[i].first - 1);
    }
    vector<int>li, opt;
    dfs (0, adj, li, 0);
    int r = N-1, l = 0;
    while (l < r){
        int m = (l+r)/2;
        opt.clear();
        for (int i= 0; i <= m; ++i)opt.push_back(li[i] + 1);
        if (query(opt))r = m;
        else l = m + 1;
    }
    return li[l]+ 1; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 464 KB Number of queries: 8
2 Correct 9 ms 1240 KB Number of queries: 9
3 Correct 13 ms 740 KB Number of queries: 9
4 Correct 12 ms 992 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 524 KB Number of queries: 9
2 Correct 11 ms 748 KB Number of queries: 9
3 Correct 12 ms 724 KB Number of queries: 9
4 Correct 12 ms 484 KB Number of queries: 9