QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394237#4913. 子集匹配luanmengleiCompile Error//C++17285b2024-04-20 10:29:302024-04-20 10:29:30

Judging History

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

  • [2024-04-20 10:29:30]
  • 评测
  • [2024-04-20 10:29:30]
  • 提交

answer

#include "hall.h"

int solve(int n, int k, int S) {
	int cnt = 0;
	for (int i = 0; i < n; i ++) {
		if (S >> i & 1)
			cnt += 1;
		else
			cnt -= 1;
		if (cnt == 1) {
			for (int j = 0; j <= i; j ++)
				S ^= (1 << j);
			return S;
		}
	}
	assert(false);
	return -1;
}

详细

implementer.cpp: In function ‘int main()’:
implementer.cpp:37:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         scanf("%d %d",&n,&K); assert(1<=n&&n<=27&&2*K>n);
      |         ~~~~~^~~~~~~~~~~~~~~
answer.code: In function ‘int solve(int, int, int)’:
answer.code:16:9: error: ‘assert’ was not declared in this scope
   16 |         assert(false);
      |         ^~~~~~
answer.code:2:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’?
    1 | #include "hall.h"
  +++ |+#include <cassert>
    2 |