Submission #410436

# Submission time Handle Problem Language Result Execution time Memory
410436 2021-05-22T16:59:41 Z nichke Easter Eggs (info1cup17_eastereggs) C++14
26.4 / 100
14 ms 13092 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();
	}
	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:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 1; i < euler.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
eastereggs.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
   59 | }
      | ^
# Verdict Execution time Memory Grader output
1 Partially correct 4 ms 584 KB Number of queries: 9
2 Partially correct 5 ms 684 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 9160 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 14 ms 13092 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -