Submission #360349

# Submission time Handle Problem Language Result Execution time Memory
360349 2021-01-28T03:13:05 Z amunduzbaev Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
23 ms 620 KB
#include <bits/stdc++.h>
#include "grader.h"
 
#ifndef EVAL
#include "grader.cpp"
#endif
 
#define pb push_back
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define pii pair<int, int>
 
using namespace std;
 
const int NN = 513;
vector<int> edges[NN];
vector<int> vv;
int nn;
 
void dfs(int u, int p = -1){
	vv.pb(u);
	for(auto x:edges[u]){
		if(x == p) continue;
		dfs(x, u);
	}
}

int findEgg (int N, vector < pair < int, int > > bb){
	for(int i=0;i<NN;i++) edges[i].clear();
	for(auto x:bb){
		edges[x.ff].pb(x.ss);
		edges[x.ss].pb(x.ff);
	}
	vv.clear();
	dfs(1);
	int l = 0, r = sz(vv)-1;
	
	while(l < r){
		int m = (l + r)>>1;
		vector<int> tt;
		for(int i=0;i<=m;i++) tt.pb(vv[i]);
		if(query(tt)) r = m;
		else l = m+1;
	}
	return vv[l];
}
# 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 17 ms 364 KB Number of queries: 9
3 Correct 23 ms 364 KB Number of queries: 9
4 Correct 17 ms 492 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 23 ms 364 KB Number of queries: 9
2 Correct 19 ms 364 KB Number of queries: 9
3 Correct 22 ms 440 KB Number of queries: 9
4 Correct 23 ms 620 KB Number of queries: 9