Submission #946814

# Submission time Handle Problem Language Result Execution time Memory
946814 2024-03-15T05:34:19 Z PenguinsAreCute Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
13 ms 1252 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
int pre[569], c;
vector<int> adj[569];
void dfs(int x, int p) {
	pre[x] = c++;
	for(auto i: adj[x]) if(i!=p) dfs(i, x);
}
int findEgg (int N, vector < pair < int, int > > bridges) {
	for(int i=0;++i<=N;) adj[i].clear();
	for(auto [u, v]: bridges) {
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	c=0; dfs(1,-1);
	int l=-1, r=N-1;
	while(r-l>1) {
		int m=l+r>>1;
		vector<int> v;
		for(int i=0;++i<=N;) if(pre[i]<=m) v.push_back(i);
		if(query(v)) r=m;
		else l=m;
	}
	for(int i=0;++i<=N;) if(pre[i]==r) return i;
	cout << "Beware the Ides of March\n";
	return 69;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:19:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   19 |   int m=l+r>>1;
      |         ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 1 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# Verdict Execution time Memory Grader output
1 Correct 3 ms 728 KB Number of queries: 8
2 Correct 7 ms 980 KB Number of queries: 9
3 Correct 13 ms 992 KB Number of queries: 9
4 Correct 11 ms 1252 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1000 KB Number of queries: 9
2 Correct 9 ms 1248 KB Number of queries: 9
3 Correct 11 ms 472 KB Number of queries: 9
4 Correct 12 ms 744 KB Number of queries: 9