Submission #636805

# Submission time Handle Problem Language Result Execution time Memory
636805 2022-08-30T08:54:17 Z valerikk "The Lyuboyn" code (IZhO19_lyuboyn) C++17
3 / 100
36 ms 6288 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));
	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 Incorrect 0 ms 212 KB The output is neither -1 nor the length of the answer
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "0000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 224 KB Ok
6 Correct 0 ms 224 KB Ok
7 Correct 0 ms 224 KB Ok
8 Correct 0 ms 224 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6180 KB Expected integer, but "000000000000000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Expected integer, but "0000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 6288 KB Expected integer, but "010101010011010100" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6180 KB Expected integer, but "000000000000000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 3072 KB Expected integer, but "01011001010101101" found
2 Halted 0 ms 0 KB -