Submission #636807

# Submission time Handle Problem Language Result Execution time Memory
636807 2022-08-30T08:55:40 Z valerikk "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
28 ms 6312 KB
#include <cstdio>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int N, K, T;
 
int f[1 << 19];

int read() {
	static char buf[19];
	scanf("%s", buf);
	int res = 0;
	for(int i = 0; i < N; ++i) {
		res |= (buf[i] - '0') << i;
	}
	return res;
}

void write(int x) {
	static char buf[19];
	for(int i = 0; i < N; ++i) {
		buf[i] = '0' + ((x >> i) & 1);
	}
	buf[N] = '\0';
	printf("%s\n", buf);
}


int main() {
	scanf("%d%d%d", &N, &K, &T);
	int S = read();
	
	if(!(K & 1)) {
		printf("-1\n");
		return 0;
	}
	
	f[0] = 0;
	f[1] = 1;
	for(int p = 1; p <= K; ++p) {
		for(int i = 0; i < (1 << p); ++i) {
			f[(1 << p) + i] = f[(1 << p) - i - 1] ^ (1 << p);
		}
	}
	
	for(int i = 0; i < (1 << (K + 1)); i += 2) {
		f[i] ^= (1 << (K + 1)) - 1;
	}
	
	for(int p = K + 1; p < N; ++p) {
		for(int i = 0; i < (1 << p); ++i) {
			f[(1 << p) + i] = f[(1 << p) - i - 1] ^ (1 << p) ^ ((1 << (K - 1)) - 1);
		}
	}
	
	int start = 0;
	while(f[start] != S) {
		++start;
	}
	rotate(f, f + start, f + (1 << N));
	printf("%d\n", 1 << N);
	for(int i = 0; i < (1 << N); ++i) {
		write(f[i]);
	}
}

Compilation message

lyuboyn.cpp: In function 'int read()':
lyuboyn.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%s", buf);
      |  ~~~~~^~~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  scanf("%d%d%d", &N, &K, &T);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 0 ms 212 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 0 ms 212 KB Ok
8 Correct 0 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 27 ms 6312 KB Ok
2 Correct 15 ms 3156 KB Ok
3 Correct 0 ms 292 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 1 ms 412 KB Ok
3 Correct 13 ms 3112 KB Ok
4 Correct 7 ms 1604 KB Ok
5 Correct 0 ms 292 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 3 ms 852 KB Ok
8 Correct 1 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 26 ms 6248 KB Ok
2 Correct 27 ms 6220 KB Ok
3 Correct 26 ms 6288 KB Ok
4 Correct 13 ms 3156 KB Ok
5 Correct 15 ms 3092 KB Ok
6 Correct 7 ms 1608 KB Ok
7 Correct 6 ms 1620 KB Ok
8 Correct 3 ms 852 KB Ok
9 Correct 3 ms 852 KB Ok
10 Correct 2 ms 596 KB Ok
11 Correct 0 ms 292 KB Ok
12 Correct 0 ms 212 KB Ok
13 Correct 1 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 27 ms 6312 KB Ok
2 Correct 15 ms 3156 KB Ok
3 Correct 0 ms 292 KB Ok
4 Correct 0 ms 212 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 0 ms 212 KB Ok
7 Correct 1 ms 412 KB Ok
8 Correct 13 ms 3112 KB Ok
9 Correct 7 ms 1604 KB Ok
10 Correct 0 ms 292 KB Ok
11 Correct 0 ms 212 KB Ok
12 Correct 3 ms 852 KB Ok
13 Correct 1 ms 212 KB Ok
14 Correct 26 ms 6248 KB Ok
15 Correct 27 ms 6220 KB Ok
16 Correct 26 ms 6288 KB Ok
17 Correct 13 ms 3156 KB Ok
18 Correct 15 ms 3092 KB Ok
19 Correct 7 ms 1608 KB Ok
20 Correct 6 ms 1620 KB Ok
21 Correct 3 ms 852 KB Ok
22 Correct 3 ms 852 KB Ok
23 Correct 2 ms 596 KB Ok
24 Correct 0 ms 292 KB Ok
25 Correct 0 ms 212 KB Ok
26 Correct 1 ms 212 KB Ok
27 Correct 27 ms 6212 KB Ok
28 Correct 17 ms 3148 KB Ok
29 Correct 27 ms 6300 KB Ok
30 Correct 2 ms 552 KB Ok
31 Correct 0 ms 212 KB Ok
32 Correct 1 ms 340 KB Ok
33 Correct 4 ms 852 KB Ok
34 Correct 0 ms 212 KB Ok
35 Correct 0 ms 212 KB Ok
36 Correct 0 ms 212 KB Ok
37 Correct 0 ms 212 KB Ok
38 Correct 14 ms 3084 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3164 KB Ok
2 Correct 26 ms 6220 KB Ok
3 Correct 27 ms 6288 KB Ok
4 Correct 2 ms 596 KB Ok
5 Correct 0 ms 212 KB Ok
6 Correct 4 ms 852 KB Ok
7 Correct 28 ms 6280 KB Ok
8 Correct 0 ms 212 KB Ok
9 Correct 0 ms 212 KB Ok
10 Correct 0 ms 296 KB Ok
11 Correct 7 ms 1572 KB Ok
12 Correct 13 ms 3064 KB Ok