답안 #1099586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099586 2024-10-11T18:17:43 Z Choco Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
14 ms 504 KB
#include <bits/stdc++.h>
#include "grader.h"
#define ll long long
using namespace std;
vector<ll>v[513];
vector<int>order;
void dfs(int i,int p){
    order.push_back(i);
    for(ll j: v[i])
    if(j!=p)
    dfs(j,i);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i=0;i<513;i++){
    v[i].clear();
    }
    order.clear();
    for(pair<int,int> i: bridges){
        int x=i.first;
        int y=i.second;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,0);
    int l=0,r=N-1;
    while(l!=r){
        ll mid=(l+r+1)/2;
        if(query(vector<int>(order.begin(),order.begin()+mid)))
        r=mid-1;
        else
        l=mid;
    }
    return order[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Number of queries: 4
2 Correct 0 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 0 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Number of queries: 8
2 Correct 6 ms 344 KB Number of queries: 9
3 Correct 9 ms 344 KB Number of queries: 9
4 Correct 8 ms 504 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 344 KB Number of queries: 9
2 Correct 8 ms 344 KB Number of queries: 9
3 Correct 11 ms 344 KB Number of queries: 9
4 Correct 14 ms 344 KB Number of queries: 9