Submission #116003

# Submission time Handle Problem Language Result Execution time Memory
116003 2019-06-10T07:08:49 Z ntrung03 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
29 ms 384 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;
vector<int> tour;
vector<vector<int>> adj;
void dfs(int u,int e){
	tour.push_back(u);
	for(auto v:adj[u])
	if(v!=e) dfs(v,u);
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
	tour.clear();
	tour.push_back(0);
	adj.clear();
	adj.resize(N+1);
	for(auto e:bridges){
		adj[e.first].push_back(e.second);
		adj[e.second].push_back(e.first);
	}
	dfs(1,-1);
	int r = 0;
	for(int i=log2(N);i>=0;i--){
		int t = r|(1<<i);
		if(t>=N) continue;
		vector<int> q(next(tour.begin()),next(tour.begin(),t+1));
//		cout<<t<<endl;
		if(!query(q)) r=t;
	}
//	cout<<tour[r]<<endl;
	return tour[r+1];
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Number of queries: 4
2 Correct 2 ms 256 KB Number of queries: 4
3 Correct 3 ms 256 KB Number of queries: 4
4 Correct 3 ms 384 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Number of queries: 8
2 Correct 13 ms 384 KB Number of queries: 9
3 Correct 29 ms 384 KB Number of queries: 9
4 Correct 15 ms 256 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 18 ms 384 KB Number of queries: 9
2 Correct 16 ms 384 KB Number of queries: 9
3 Correct 17 ms 256 KB Number of queries: 9
4 Correct 19 ms 304 KB Number of queries: 9