답안 #890562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
890562 2023-12-21T13:19:52 Z Iwantbemaster Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
12 ms 1008 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int i, cur[1005];
vector<int> result[1005];
void DFS(int res, int ans){
	cur[++i] = res;
	for(auto to : result[res]){
		if(to == ans) continue;
		DFS(to, res);
	}
}
int Query(int res){
	vector<int> v;
	for(int i = 1; i <= res; i++) v.push_back(cur[i]);
	return query(v);
}

int findEgg(int n, vector<pair<int, int>> bridges){
	for(int i = 1; i <= n; i++) result[i].clear();
	for(auto e: bridges){
		result[e.first].push_back(e.second);
		result[e.second].push_back(e.first);
	} i = 0; DFS(1, 0);
	int l = 1, r = n;
	while(l < r){
		int m = l + (r - l) / 2;
		if(Query(m)) r = m;
		else l = m + 1;
	} return cur[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 596 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 480 KB Number of queries: 8
2 Correct 7 ms 744 KB Number of queries: 9
3 Correct 11 ms 764 KB Number of queries: 9
4 Correct 10 ms 1008 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 772 KB Number of queries: 9
2 Correct 9 ms 724 KB Number of queries: 9
3 Correct 12 ms 1008 KB Number of queries: 9
4 Correct 10 ms 756 KB Number of queries: 9