답안 #480532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480532 2021-10-16T19:39:11 Z Haidara Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
21 ms 456 KB
#include<bits/stdc++.h>
#include<grader.h>
#define ff first 
#define ss second
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
using namespace std;
const int maxn=550;
vector<int>graph[maxn],ord;
void dfs(int st=1,int par=-1)
{
	ord.push_back(st);
    for(auto i:graph[st])
    {
    	if(i==par)
    		continue;
    	dfs(i,st);
    }
}
bool go=1;
int findEgg(int n,vector< pair<int,int> >edges)
{
if(go){
    for(auto i:edges)
    {
        graph[i.ff].push_back(i.ss);
        graph[i.ss].push_back(i.ff);
    }
    dfs();
    go=0;}    
    int l=0,r=n-1;
    while(l<r)
    {
    	int mid=l+(r-l)/2;
    	if(query(vector<int>(ord.begin(),ord.begin()+mid+1)))
    		r=mid;
    	else 
    		l=mid+1;
    }
    return ord[r];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 200 KB Number of queries: 4
2 Correct 1 ms 260 KB Number of queries: 4
3 Correct 2 ms 200 KB Number of queries: 4
4 Correct 1 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 328 KB Number of queries: 8
2 Correct 12 ms 344 KB Number of queries: 9
3 Correct 14 ms 456 KB Number of queries: 9
4 Correct 15 ms 328 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 356 KB Number of queries: 9
2 Correct 16 ms 328 KB Number of queries: 9
3 Correct 21 ms 328 KB Number of queries: 9
4 Correct 17 ms 328 KB Number of queries: 9