답안 #403590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403590 2021-05-13T09:51:19 Z hltk Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
24 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
#include "grader.h"
int findEgg(int n, vector<pair<int, int>> bridges) {
	vector<vector<int>> g(n + 1);
	for (auto [a, b] : bridges) {
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ord;
	function<void(int, int)> dfs = [&](int v, int p) {
		ord.push_back(v);
		for (int u : g[v]) {
			if (u == p) continue;
			dfs(u, v);
		}
	};
	dfs(1, -1);
	int l = 0, r = (int) ord.size() - 1;
	while (l < r) {
		int m = (l + r) / 2;
		if (query({ord.begin(), ord.begin() + m + 1})) r = m;
		else l = m + 1;
	}
	return ord[l];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Number of queries: 4
2 Correct 2 ms 200 KB Number of queries: 4
3 Correct 1 ms 200 KB Number of queries: 4
4 Correct 2 ms 200 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 328 KB Number of queries: 8
2 Correct 15 ms 328 KB Number of queries: 9
3 Correct 22 ms 328 KB Number of queries: 9
4 Correct 20 ms 468 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 380 KB Number of queries: 9
2 Correct 24 ms 344 KB Number of queries: 9
3 Correct 21 ms 328 KB Number of queries: 9
4 Correct 19 ms 328 KB Number of queries: 9