Submission #343760

# Submission time Handle Problem Language Result Execution time Memory
343760 2021-01-04T13:03:22 Z Kerim Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
22 ms 416 KB
#include <bits/stdc++.h>
#include "grader.h"
#define pb(x) push_back(x)
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define MAXN 512
using namespace std;
vector<int>adj[MAXN],v;
void dfs(int nd,int pr){
	v.pb(nd);
	tr(it,adj[nd])
		if(*it!=pr)
			dfs(*it,nd);	
}
int findEgg (int N, vector < pair < int, int > > bridges){
	for(int i=0;i<N;i++)adj[i].clear();
	v.clear();
	for(int i=0;i<N-1;i++){
		int u=bridges[i].first-1;
		int v=bridges[i].second-1;
		adj[u].pb(v);adj[v].pb(u);	
	}
	dfs(0,-1);
	int st=0,en=N-1;
	while(st<en){
		int mid=(st+en)>>1;
		vector<int>cur;
		for(int i=0;i<=mid;i++)cur.pb(v[i]+1);
		if(query(cur))en=mid;
		else st=mid+1;
	}
    return v[st]+1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Number of queries: 4
2 Correct 1 ms 364 KB Number of queries: 4
3 Correct 1 ms 364 KB Number of queries: 4
4 Correct 1 ms 364 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Number of queries: 8
2 Correct 13 ms 364 KB Number of queries: 9
3 Correct 18 ms 416 KB Number of queries: 9
4 Correct 20 ms 364 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 22 ms 364 KB Number of queries: 9
2 Correct 17 ms 364 KB Number of queries: 9
3 Correct 19 ms 364 KB Number of queries: 9
4 Correct 21 ms 364 KB Number of queries: 9