Submission #502727

# Submission time Handle Problem Language Result Execution time Memory
502727 2022-01-06T14:01:54 Z sidon Minerals (JOI19_minerals) C++17
Compilation error
0 ms 0 KB
#include "minerals.h"

int A[43000], L, R = -1, last;

void dfs(int l, int r, auto b, bool on) {
	if(r - l < 1) return;
	if(r - l < 2) return Answer(A[l], b[0]);

	int m = (l + r) / 2;
	if(l < m-1 && m - l == r - m) --m;
	while(__builtin_popcount(m-l) > 2) --m;

	for(int i = l; i < m; ++i) last = Query(A[i]);

	std::vector<int> bL, bR;

	for(int &i : b) {
		int prev = last;
		(size(bR) == r - m || (size(bL) != m - l && (prev == (last = Query(i))) ^ on) ? bL : bR).push_back(i);
	}
	dfs(l, m, bL, on ^ 1);
	dfs(m, r, bR, on);
}

void Solve(int N) {
	std::vector<int> b;
	for(int i = 1; i <= N+N; ++i) 
		if(R == N - 1 || Query(i) < R + 2) b.push_back(i);
		else A[++R] = i;
	dfs(0, N, b, 1);
}

Compilation message

minerals.cpp:5:24: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
    5 | void dfs(int l, int r, auto b, bool on) {
      |                        ^~~~
minerals.cpp: In function 'void dfs(int, int, auto:1, bool)':
minerals.cpp:15:7: error: 'vector' is not a member of 'std'
   15 |  std::vector<int> bL, bR;
      |       ^~~~~~
minerals.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "minerals.h"
  +++ |+#include <vector>
    2 | 
minerals.cpp:15:14: error: expected primary-expression before 'int'
   15 |  std::vector<int> bL, bR;
      |              ^~~
minerals.cpp:19:9: error: 'bR' was not declared in this scope; did you mean 'b'?
   19 |   (size(bR) == r - m || (size(bL) != m - l && (prev == (last = Query(i))) ^ on) ? bL : bR).push_back(i);
      |         ^~
      |         b
minerals.cpp:19:4: error: there are no arguments to 'size' that depend on a template parameter, so a declaration of 'size' must be available [-fpermissive]
   19 |   (size(bR) == r - m || (size(bL) != m - l && (prev == (last = Query(i))) ^ on) ? bL : bR).push_back(i);
      |    ^~~~
minerals.cpp:19:4: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
minerals.cpp:19:31: error: 'bL' was not declared in this scope; did you mean 'b'?
   19 |   (size(bR) == r - m || (size(bL) != m - l && (prev == (last = Query(i))) ^ on) ? bL : bR).push_back(i);
      |                               ^~
      |                               b
minerals.cpp:19:26: error: there are no arguments to 'size' that depend on a template parameter, so a declaration of 'size' must be available [-fpermissive]
   19 |   (size(bR) == r - m || (size(bL) != m - l && (prev == (last = Query(i))) ^ on) ? bL : bR).push_back(i);
      |                          ^~~~
minerals.cpp:21:12: error: 'bL' was not declared in this scope; did you mean 'b'?
   21 |  dfs(l, m, bL, on ^ 1);
      |            ^~
      |            b
minerals.cpp:22:12: error: 'bR' was not declared in this scope; did you mean 'b'?
   22 |  dfs(m, r, bR, on);
      |            ^~
      |            b
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:26:7: error: 'vector' is not a member of 'std'
   26 |  std::vector<int> b;
      |       ^~~~~~
minerals.cpp:26:7: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
minerals.cpp:26:14: error: expected primary-expression before 'int'
   26 |  std::vector<int> b;
      |              ^~~
minerals.cpp:28:38: error: 'b' was not declared in this scope
   28 |   if(R == N - 1 || Query(i) < R + 2) b.push_back(i);
      |                                      ^
minerals.cpp:30:12: error: 'b' was not declared in this scope
   30 |  dfs(0, N, b, 1);
      |            ^