Submission #649457

# Submission time Handle Problem Language Result Execution time Memory
649457 2022-10-10T08:45:02 Z elif Easter Eggs (info1cup17_eastereggs) C++17
80 / 100
15 ms 512 KB
#include <bits/stdc++.h>
#include "grader.h"
// #include "grader.cpp"
using namespace std;

vector<int> adj[513];
vector<int> v;

void dfs(int u, int p){
	v.push_back(u);
	for(auto x : adj[u]){
		if(x != p)
			dfs(x, u);
	}
}
int findEgg(int N, vector<pair<int, int>> bridges){

	ios_base::sync_with_stdio(0);

	for(int i=0; i<N-1; i++){
		int u = bridges[i].first;
		int v = bridges[i].second;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	dfs(1, 0);

	int sz = v.size();
	int ans = -1;
	int l = 0, r = sz - 2;
	while(l <= r){
		vector<int> islands;
		int mid = (l + r) / 2;
		for(int i=0; i<=mid; i++)
			islands.push_back(v[i]);
		
		if(query(islands) == 1){
			ans = mid;
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	if(ans == -1)
		ans = sz - 1;

	v.clear();
	for(int i=0; i<512; i++)
		adj[i].clear();

	return v[ans];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Number of queries: 4
2 Correct 1 ms 208 KB Number of queries: 4
3 Correct 2 ms 208 KB Number of queries: 4
4 Correct 1 ms 208 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 4 ms 356 KB Number of queries: 8
2 Correct 11 ms 384 KB Number of queries: 9
3 Correct 15 ms 376 KB Number of queries: 9
4 Correct 14 ms 376 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -