Submission #332570

# Submission time Handle Problem Language Result Execution time Memory
332570 2020-12-02T21:47:00 Z codemaster111 Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
22 ms 620 KB
#include <bits/stdc++.h>
#include "grader.h"
 
using namespace std;
#define pb push_back
#define f first
#define s second
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define trav(i, x) for(auto& i:x)
 
const int mx = 550;
vector<int> adj[mx], ans;
 
void dfs(int i, int p) {
	ans.pb(i);
	trav(u, adj[i]) {
		if (u != p)
			dfs(u, i);
	}
}
 
int findEgg (int N, vector < pair < int, int > > bridges)
{
	FOR(i, 0, mx)
		adj[i].clear();
	trav(ii, bridges)
		adj[ii.f].pb(ii.s), adj[ii.s].pb(ii.f);
 
	dfs(1, 0);
 
	//2^9=512
	// bin search on search vector for ans
	int lo = 0, hi = N-1;
	while (lo != hi) {
		int mid = (lo+hi+1)/2;
		vector<int> cur(ans.begin(), ans.begin()+mid);
		if (query(cur))
			hi = mid-1;
		else
			lo = mid;
	}
	return ans[lo];
}
# 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 16 ms 492 KB Number of queries: 9
3 Correct 21 ms 620 KB Number of queries: 9
4 Correct 22 ms 620 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 20 ms 620 KB Number of queries: 9
2 Correct 18 ms 620 KB Number of queries: 9
3 Correct 19 ms 620 KB Number of queries: 9
4 Correct 19 ms 620 KB Number of queries: 9