Submission #410440

# Submission time Handle Problem Language Result Execution time Memory
410440 2021-05-22T17:02:42 Z nichke Easter Eggs (info1cup17_eastereggs) C++14
26.4 / 100
14 ms 13000 KB
#include <bits/stdc++.h>
using namespace std;

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

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

bool query(vector < int > v);

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();
	}
	int root = 1;
	for (auto it : bridges) {
		root = it.first;
		adj[it.first].push_back(it.second);
		adj[it.second].push_back(it.first);
	}
	dfs(root, root);
	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:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 1; i < euler.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
eastereggs.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
# Verdict Execution time Memory Grader output
1 Partially correct 3 ms 604 KB Number of queries: 9
2 Partially correct 4 ms 604 KB Number of queries: 9
3 Partially correct 4 ms 584 KB Number of queries: 9
4 Partially correct 4 ms 584 KB Number of queries: 9
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8400 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 13000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -