Submission #1136873

#TimeUsernameProblemLanguageResultExecution timeMemory
1136873mnbvcxz123Koala Game (APIO17_koala)C++20
Compilation error
0 ms0 KiB
inline bool compare(int a, int b, int N, int W) {
	fill(B, B + N, 0);
	B[a] = B[b] = W;
	playRound(B, R);
	return (R[b] > W);
}
vector<int> mergesort(vector<int> v, int N, int W) {
	if (v.size() == 1) return v;

	vector<int> a, b;
	a.insert(a.begin(), v.begin(), v.begin() + (v.size() + 1) / 2);
	b.insert(b.begin(), v.begin() + (v.size() + 1) / 2, v.end());
	a = mergesort(a, N, W), b = mergesort(b, N, W);

	vector<int> sorted;
	int aptr = 0, bptr = 0;
	while (aptr < a.size() && bptr < b.size()) {
		if (compare(a[aptr], b[bptr], N, W)) sorted.push_back(a[aptr++]);
		else sorted.push_back(b[bptr++]);
	}
	sorted.insert(sorted.end(), a.begin() + aptr, a.end());
	sorted.insert(sorted.end(), b.begin() + bptr, b.end());

	return sorted;
}

void allValues(int N, int W, int *P) {
	if (W == 2 * N) {
		vector<int> v;
		for (int i = 0; i < N; i++) v.push_back(i);
		vector<int> sorted = mergesort(v, N, W / 2);
		for (int i = 0; i < N; i++) P[sorted[i]] = i + 1;
	}
}

Compilation message (stderr)

koala.cpp: In function 'bool compare(int, int, int, int)':
koala.cpp:2:14: error: 'B' was not declared in this scope
    2 |         fill(B, B + N, 0);
      |              ^
koala.cpp:2:9: error: 'fill' was not declared in this scope
    2 |         fill(B, B + N, 0);
      |         ^~~~
koala.cpp:4:22: error: 'R' was not declared in this scope
    4 |         playRound(B, R);
      |                      ^
koala.cpp:4:9: error: 'playRound' was not declared in this scope
    4 |         playRound(B, R);
      |         ^~~~~~~~~
koala.cpp: At global scope:
koala.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> mergesort(vector<int> v, int N, int W) {
      | ^~~~~~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:29:17: error: 'vector' was not declared in this scope
   29 |                 vector<int> v;
      |                 ^~~~~~
koala.cpp:29:24: error: expected primary-expression before 'int'
   29 |                 vector<int> v;
      |                        ^~~
koala.cpp:30:45: error: 'v' was not declared in this scope
   30 |                 for (int i = 0; i < N; i++) v.push_back(i);
      |                                             ^
koala.cpp:31:24: error: expected primary-expression before 'int'
   31 |                 vector<int> sorted = mergesort(v, N, W / 2);
      |                        ^~~
koala.cpp:32:47: error: 'sorted' was not declared in this scope
   32 |                 for (int i = 0; i < N; i++) P[sorted[i]] = i + 1;
      |                                               ^~~~~~