Submission #410434

# Submission time Handle Problem Language Result Execution time Memory
410434 2021-05-22T16:58:34 Z nichke Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> adj[513];
vector<int> euler;

set<int> pref[513];
vector<int> vi;

void dfs(int v, int p) {
	euler.push_back(v);
	for (int u : adj[v]) {
		if (u == p) continue;
		dfs(u, v);
		euler.push_back(v);
	}
}

int findEgg(int N, vector< pair <int, int> > bridges) {
	for (int i = 0; i < 513; i++) {
		adj[i].clear();
	}
	for (auto it : bridges) {
		adj[it.first].push_back(it.second);
		adj[it.second].push_back(it.first);
	}
	dfs(1, 1);
	pref[0].insert(euler[0]);
	for (int i = 1; i < euler.size(); i++) {
		pref[i] = pref[i - 1];
		pref[i].insert(euler[i]);
	}
	int l = 0, r = euler.size() - 1;
	int flag = -1;
	while (l <= r) {
		vi.clear();
		int m = (l + r) / 2;
		for (int i : pref[m]) {
			vi.push_back(i);
		}
		int k = query(vi);
		if (k) {
			flag = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	if (flag) {
		for (int i : pref[flag - 1]) {
			pref[flag].erase(i);
		}
	}
	for (int i : pref[flag]) {
		return i;
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i = 1; i < euler.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
eastereggs.cpp:41:11: error: 'query' was not declared in this scope
   41 |   int k = query(vi);
      |           ^~~~~
eastereggs.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
   57 | }
      | ^