Submission #279654

# Submission time Handle Problem Language Result Execution time Memory
279654 2020-08-22T09:14:51 Z MKutayBozkurt Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
30 ms 680 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

vector<vector<int>> v;
vector<int> a;

void dfs(int i, int last = -1) {
	a.emplace_back(i);
	for (auto node : v[i]) {
		if (last == node) continue;
		dfs(node, i);
	}
}

int findEgg (int n, vector<pair<int, int>> bridges) {
	v = vector<vector<int>>(n + 10);
	for (auto node : bridges) {
		v[node.first].emplace_back(node.second);
		v[node.second].emplace_back(node.first);
	}
	dfs(1);
	int l = 0, r = n - 1;
	while (l < r) {
		int m = (l + r) / 2;
		if (query(vector<int>(a.begin(), a.begin() + m + 1))) r = m;
		else l = m + 1;
	}
	return a[l];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Number of queries: 4
2 Correct 1 ms 256 KB Number of queries: 4
3 Correct 1 ms 256 KB Number of queries: 4
4 Correct 1 ms 256 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Number of queries: 8
2 Correct 15 ms 504 KB Number of queries: 9
3 Correct 23 ms 628 KB Number of queries: 9
4 Correct 26 ms 624 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 22 ms 680 KB Number of queries: 9
2 Correct 19 ms 624 KB Number of queries: 9
3 Correct 30 ms 624 KB Number of queries: 9
4 Correct 26 ms 624 KB Number of queries: 9