QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#132847#6661. 야유회5sbCompile Error//C++23896b2023-07-31 19:42:112023-07-31 19:42:13

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-31 19:42:13]
  • 评测
  • [2023-07-31 19:42:11]
  • 提交

answer

#include <vector>

constexpr int n[3] = {100000, 20, 6};
constexpr int m[3] = {10, 3, 2};

std::vector a[3];

void init() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; (int)a[i].size() < n[i] && j < (1 << (m[i] * 2)); j++) {
			if (__builtin_popcount(j) == m[i]) {
				a[i].push_back(j);
			}
		}
		assert((int)a[i].size() == n[i]);
	}
}

int f(int i, int x, int y) {
	x = a[i][x - 1], y = a[i][y - 1];
	for (int i = 0; i < m[i] * 2; i++) {
		if (((x >> i) & 1) == 0 && ((y >> i) & 1) == 1) {
			return i;
		}
	}
	assert(false);
	return -1;
}

int morning(int m, int r) {
	return f(0, m, r);
}

int afternoon(int l, int m, int r) {
	return f(2, f(1, l, m), f(1, m, r));
}

int evening(int l, int m, int r) {
	if (m < 3) {
		return m;
	}
	for (int i = 0; i < 3; i++) {
		if (i != l && i != r) {
			return i;
		}
	}
	assert(false);
	return -1;
}

Details

answer.code:6:1: error: template placeholder type ‘vector<...auto...>’ must be followed by a simple declarator-id
    6 | std::vector a[3];
      | ^~~
In file included from /usr/include/c++/11/vector:67,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note: ‘template<class _Tp, class _Alloc> class std::vector’ declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
answer.code: In function ‘void init()’:
answer.code:10:38: error: ‘a’ was not declared in this scope
   10 |                 for (int j = 0; (int)a[i].size() < n[i] && j < (1 << (m[i] * 2)); j++) {
      |                                      ^
answer.code:15:29: error: ‘a’ was not declared in this scope
   15 |                 assert((int)a[i].size() == n[i]);
      |                             ^
answer.code:15:17: error: ‘assert’ was not declared in this scope
   15 |                 assert((int)a[i].size() == n[i]);
      |                 ^~~~~~
answer.code:2:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    1 | #include <vector>
  +++ |+#include <cassert>
    2 | 
answer.code: In function ‘int f(int, int, int)’:
answer.code:20:13: error: ‘a’ was not declared in this scope
   20 |         x = a[i][x - 1], y = a[i][y - 1];
      |             ^
answer.code:26:9: error: ‘assert’ was not declared in this scope
   26 |         assert(false);
      |         ^~~~~~
answer.code:26:9: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
answer.code: In function ‘int evening(int, int, int)’:
answer.code:47:9: error: ‘assert’ was not declared in this scope
   47 |         assert(false);
      |         ^~~~~~
answer.code:47:9: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?