Submission #522160

# Submission time Handle Problem Language Result Execution time Memory
522160 2022-02-04T01:40:24 Z boykut Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
7 ms 628 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

vector<int> g[555];
vector<int> vertex;

void dfs(int v, int p = -1) {
	vertex.push_back(v);
	for (auto to : g[v]) {
		if (to != p) {
			dfs(to, v);
		}
	}
}

int check(int len) {
}

int findEgg (int N, vector < pair < int, int > > bridges){
	vector<vector<int>> g(N);
	vector<int> vertex;
	for (auto it : bridges) {
		g[it.first - 1].push_back(it.second - 1);
		g[it.second - 1].push_back(it.first - 1);
	}
	function<void(int,int)> dfs = [&](int v, int p) {
		vertex.push_back(v);
		for (int to : g[v]) {
			if (to != p) {
				dfs(to, v);
				vertex.push_back(v);
			}
		}
	};
	int mn_cnt = 2e9, root = -1;
	for (int i = 0; i < N; i++) {
		while (!vertex.empty()) vertex.pop_back();
		dfs(i, -1);
		if (vertex.size() < mn_cnt) {
			mn_cnt = vertex.size();
			root = i;
		}
	}
	while (!vertex.empty()) vertex.pop_back();
	dfs(root, -1);
	int l = 0, r = vertex.size() - 1;
	while (l < r) {
		int m = (l + r) / 2;
		vector<int> Q;
		for (int i = l; i <= m; i++) Q.push_back(vertex[i] + 1);
		if (query(Q) == 1)
			r = m;
		else
			l = m + 1;
	}
	return vertex[r] + 1;
}

Compilation message

eastereggs.cpp: In function 'int check(int)':
eastereggs.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:41:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |   if (vertex.size() < mn_cnt) {
      |       ~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 628 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -