Submission #773765

# Submission time Handle Problem Language Result Execution time Memory
773765 2023-07-05T08:14:45 Z khshg Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int findEgg(int N, vector<pair<int, int>> bridges) {
	vector<vector<int>> adj(N);
	for(auto& u : bridges) {
		--u.first; --u.second;
		adj[u.first].push_back(u.second);
		adj[u.second].push_back(u.first);
	}
	vector<bool> good(N, 1);
	int sum = N;
	while(sum > 1) {
		vector<int> ask;
		vector<pair<int, int>> q;
		int goal = sum / 2;
		q.push_back({0, -1});
		while(true) {
			pair<int, int> s = q.back(); q.pop_back();
			ask.push_back(s.first);
			goal -= good[s.first];
			if(goal == 0) break;
			for(int& u : adj[s.first]) {
				if(u != s.second) {
					q.push_back({u, s.first});
				}
			}
		}
		bool f = query(ask);
		vector<bool> ch(N);
		for(auto& u : ask) ch[u] = 1;
		sum = 0;
		for(int i = 0; i < N; ++i) {
			if(good[i]) good[i] = (f ? ch[i] : !ch[i]);
			sum += good[i];
		}
	}
	for(int i = 0; i < N; ++i) if(good[i]) return i + 1;
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:12: error: 'query' was not declared in this scope
   29 |   bool f = query(ask);
      |            ^~~~~
eastereggs.cpp:5:27: warning: control reaches end of non-void function [-Wreturn-type]
    5 |  vector<vector<int>> adj(N);
      |                           ^