Submission #128622

# Submission time Handle Problem Language Result Execution time Memory
128622 2019-07-11T07:42:43 Z sheyasutaka Easter Eggs (info1cup17_eastereggs) C++14
Compilation error
0 ms 0 KB
#include <vector>
using std::vector;
usign std:pair;
typedef pair<int, int> P;

vector<int> g[600];
vector<int> euler;

void dfs (int v, int p) {
	euler.push_back(v);

	for (int u : g[v]) {
		if (u == p) continue;
		dfs(u, v);
	}
}

int findEgg (int N, P bridges) {
	int i, j;

	for (i = 0; i < g.size(); i++) {
		g[i].clear();
	}
	euler.clear();

	for (i = 0; i < N - 1; i++) {
		g[bridges[i].first - 1].push_back(bridges[i].second - 1);
		g[bridges[i].second - 1].push_back(bridges[i].first - 1);
	}

	dfs(0, N);

	int l = 0, r = N;
	while (l + 1 < r) {
		int med = (l + r) / 2;

		vector<int> v;
		for (i = 0; i < med; i++) {
			v.push_back(euler[i] + 1);
		}
		if (query(v)) {
			r = med;
		} else {
			l = med;
		}
	}
	return euler[l] + 1;
}

Compilation message

eastereggs.cpp:4:1: error: 'usign' does not name a type; did you mean 'union'?
 usign std:pair;
 ^~~~~
 union
eastereggs.cpp:5:9: error: 'pair' does not name a type
 typedef pair<int, int> P;
         ^~~~
eastereggs.cpp:19:21: error: 'P' has not been declared
 int findEgg (int N, P bridges) {
                     ^
eastereggs.cpp: In function 'int findEgg(int, int)':
eastereggs.cpp:22:20: error: request for member 'size' in 'g', which is of non-class type 'std::vector<int> [600]'
  for (i = 0; i < g.size(); i++) {
                    ^~~~
eastereggs.cpp:28:14: error: invalid types 'int[int]' for array subscript
   g[bridges[i].first - 1].push_back(bridges[i].second - 1);
              ^
eastereggs.cpp:28:46: error: invalid types 'int[int]' for array subscript
   g[bridges[i].first - 1].push_back(bridges[i].second - 1);
                                              ^
eastereggs.cpp:29:14: error: invalid types 'int[int]' for array subscript
   g[bridges[i].second - 1].push_back(bridges[i].first - 1);
              ^
eastereggs.cpp:29:47: error: invalid types 'int[int]' for array subscript
   g[bridges[i].second - 1].push_back(bridges[i].first - 1);
                                               ^
eastereggs.cpp:42:7: error: 'query' was not declared in this scope
   if (query(v)) {
       ^~~~~
eastereggs.cpp:20:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^