답안 #291065

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291065 2020-09-04T16:02:10 Z PeppaPig "The Lyuboyn" code (IZhO19_lyuboyn) C++14
19 / 100
611 ms 6764 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1 << 19;

int n, k, t, s;
mt19937 rng(time(NULL));

void print(int val) {
	vector<int> vec;
	for(int i = 0; i < n; i++, val >>= 1)
		vec.emplace_back(val & 1);
	reverse(vec.begin(), vec.end());
	for(int x : vec) printf("%d", x);
	printf("\n");
}

int ans[N];
vector<int> base;

bool is_basis() {
	vector<int> mat(base.begin(), base.begin() + n);
	for(int i = n - 1; ~i; i--) {
		int val = -1;
		for(int x : mat) if(x >> i & 1) val = x;
		if(val == -1) return false;
		for(int &x : mat) if(x != val && (x >> i & 1))
			x ^= val;	
	}
	return true;
}

int main() {
	char input[100];
	scanf("%d %d %d %s", &n, &k, &t, input);
	if(k % 2 == 0) return !printf("-1\n");

	for(int i = 0; input[i] != '\0'; i++)
		s = (s << 1) + (input[i] == '1');

	for(int i = 0; i < (1 << n); i++) if(__builtin_popcount(i) == k)
		base.emplace_back(i);

	while(!is_basis()) shuffle(base.begin(), base.end(), rng);

	ans[0] = s;
	int ptr = 1, valid = 1;
	for(int j = 0; j < n; j++) for(int i = ptr - 1; ~i; i--)
		ans[ptr++] = ans[i] ^ base[j];

	if(valid) {
		printf("%d\n", (1 << n));
		for(int i = 0; i < (1 << n); i++) print(ans[i]);
		exit(0);
	}

	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   36 |  scanf("%d %d %d %s", &n, &k, &t, input);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Ok
2 Correct 0 ms 256 KB Ok
3 Correct 1 ms 256 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
6 Correct 0 ms 256 KB Ok
7 Correct 0 ms 256 KB Ok
8 Correct 1 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 556 ms 6520 KB Ok
2 Correct 257 ms 3192 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 1 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 588 ms 6764 KB The values in the output sequence are not pairwise distinct!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 556 ms 6520 KB Ok
2 Correct 257 ms 3192 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 1 ms 256 KB Ok
6 Incorrect 1 ms 256 KB The values in the output sequence are not pairwise distinct!
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 267 ms 3316 KB Ok
2 Correct 566 ms 6392 KB Ok
3 Correct 611 ms 6700 KB Ok
4 Incorrect 29 ms 640 KB The values in the output sequence are not pairwise distinct!
5 Halted 0 ms 0 KB -