Submission #116009

# Submission time Handle Problem Language Result Execution time Memory
116009 2019-06-10T07:14:11 Z tuanasanh Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
15 ms 384 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> t;
vector<int> adj[600];
void dfs(int node,int par){
	t.push_back(node);
	for(auto u:adj[node]){
		if(u!=par) dfs(u,node);
	}
}
bool check(int m){
	vector<int> tmp;
	for(int i=0;i<=m;i++) tmp.push_back(t[i]);
	return query(tmp);
}
int findEgg (int n, vector < pair < int, int > > bridges)
{
    if(t.empty()){
    	for(auto p:bridges){
    		adj[p.first].push_back(p.second);
    		adj[p.second].push_back(p.first);
		}
		dfs(1,0);
	}
	int l=0,r=n-1;
	while(l<r){
		int m=(l+r)/2;
		if(check(m)) r=m;
		else l=m+1;
	}
	return t[l];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Number of queries: 4
2 Correct 2 ms 384 KB Number of queries: 4
3 Correct 3 ms 384 KB Number of queries: 4
4 Correct 2 ms 256 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Number of queries: 8
2 Correct 12 ms 360 KB Number of queries: 9
3 Correct 15 ms 256 KB Number of queries: 9
4 Correct 14 ms 368 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 14 ms 384 KB Number of queries: 9
2 Correct 14 ms 256 KB Number of queries: 9
3 Correct 14 ms 384 KB Number of queries: 9
4 Correct 15 ms 384 KB Number of queries: 9