답안 #918562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918562 2024-01-30T06:46:20 Z HaciyevAlik Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
11 ms 1260 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int mx=550;
vector<int> g[mx],order;
void dfs(int u,int p) {
    order.push_back(u);
    for(int v:g[u]) {
        if(v!=p) dfs(v,u);
    }
}
int findEgg (int N,vector<pair<int,int>> bridges){
    order.clear();
    for(int i=0;i<mx;++i) g[i].clear();
    for(int i=0;i<N-1;++i) {
        int u=bridges[i].first,v=bridges[i].second;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    int l=0,r=N-1;
    while(l<r) {
        int mid=(l+r)/2;
        vector<int> temp;
        for(int i=0;i<=mid;++i) {
            temp.push_back(order[i]);
        }
        if(query(temp)) {
            r=mid;
        } else {
            l=mid+1;
        }
    }
    return order[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 352 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 352 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 720 KB Number of queries: 8
2 Correct 7 ms 744 KB Number of queries: 9
3 Correct 11 ms 496 KB Number of queries: 9
4 Correct 10 ms 736 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1004 KB Number of queries: 9
2 Correct 9 ms 472 KB Number of queries: 9
3 Correct 11 ms 984 KB Number of queries: 9
4 Correct 10 ms 1260 KB Number of queries: 9