Submission #410448

# Submission time Handle Problem Language Result Execution time Memory
410448 2021-05-22T17:14:13 Z nichke Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
1 ms 456 KB
#include <bits/stdc++.h>
using namespace std;

vector< int > vi;
vector< int > euler;
vector< int > adj[513];

int query(vector <int> );

void dfs(int v, int p = -1) {
	euler.push_back(v);
	for (int u : adj[v]) {
		if (u == p) continue;
		dfs(u, v);
	}
}

int check_query(int x) {
	vi.clear();
	for (int i = 0; i <= x; i++) {
		vi.push_back(i);
	}
	return query(vi);   
}

int findEgg(int N, vector< pair <int, int> > bridges) {
	euler.clear();
	for (int i = 1; i <= N; i++) {
		adj[i].clear();
	}
	for (int i = 0; i < N - 1; i++) {
		adj[bridges[i].first].push_back(bridges[i].second);
		adj[bridges[i].second].push_back(bridges[i].first);
	}
	dfs(1);
	int res = -1;
	int l = 0, r = euler.size() - 1;
	while (l <= r) {
		int m = (l + r) / 2;
		if (check_query(m)) {
			r = m - 1;
			res = m;
		} else {
			l = m + 1;
		}
	}
	return euler[res];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -