답안 #981395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981395 2024-05-13T06:55:48 Z batsukh2006 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
13 ms 1020 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
#define ff first
#define ss second
vector<int> o;
vector<vector<int> > v;
void dfs(int a, int p){
	o.push_back(a);
	for(auto node: v[a]){
		if(node!=p){
			dfs(node,a);
		}
	}
}
int findEgg(int N, vector<pair<int,int> > bridges){
	o.clear();
	v.clear(),v.resize(N+1);
	for(auto p: bridges){
		v[p.ff].push_back(p.ss);
		v[p.ss].push_back(p.ff);
	}
	dfs(1,1);
	int l=0,r=N-2;
	while(l<=r){
		int m=l+(r-l)/2;
		vector<int> c(m+1);
		for(int i=0; i<=m; i++) c[i]=o[i];
		if(query(c)) r=m-1;
		else l=m+1;
	}
    return o[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 736 KB Number of queries: 8
2 Correct 8 ms 1012 KB Number of queries: 9
3 Correct 12 ms 1008 KB Number of queries: 9
4 Correct 10 ms 996 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1020 KB Number of queries: 9
2 Correct 10 ms 740 KB Number of queries: 9
3 Correct 12 ms 1012 KB Number of queries: 9
4 Correct 11 ms 744 KB Number of queries: 9