답안 #360180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
360180 2021-01-27T16:05:28 Z tengiz05 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
26 ms 564 KB
#include <bits/stdc++.h>
#include "grader.h"
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;
const int MAXN = 515;
vector<int> edges[MAXN];
int n;
vector<int> a;
void dfs(int u, int p = -1){
	a.push_back(u);
	for(auto v : edges[u]){
		if(v == p)continue;
		dfs(v,u);
	}
}
int findEgg(int N, vector<pair<int,int>> bridges){
	n = N;
	for(auto [u, v] : bridges){
		edges[u].push_back(v);
		edges[v].push_back(u);
	}dfs(1);
	int l=0, r=n-1;
	while(l < r){
		int mid = (l+r)>>1;
		vector<int> toask;
		for(int i=0;i<=mid;i++){
			toask.push_back(a[i]);
		}if(query(toask))r = mid;
		else l = mid+1;
	}
	int ans = a[l];
	for(int i=1;i<=n;i++){
		edges[i].clear();
	}a.clear();
	return ans;
}



# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Number of queries: 4
2 Correct 1 ms 364 KB Number of queries: 4
3 Correct 1 ms 364 KB Number of queries: 4
4 Correct 2 ms 364 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 364 KB Number of queries: 8
2 Correct 13 ms 364 KB Number of queries: 9
3 Correct 25 ms 364 KB Number of queries: 9
4 Correct 18 ms 364 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 364 KB Number of queries: 9
2 Correct 19 ms 564 KB Number of queries: 9
3 Correct 21 ms 364 KB Number of queries: 9
4 Correct 22 ms 564 KB Number of queries: 9