Submission #636794

# Submission time Handle Problem Language Result Execution time Memory
636794 2022-08-30T08:40:05 Z valerikk "The Lyuboyn" code (IZhO19_lyuboyn) C++17
3 / 100
328 ms 6316 KB
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int N, K, T;

int f[1 << 19];

int main() {
	scanf("%d%d%d", &N, &K, &T);
	static char S[19];
	scanf("%s", S);
	int S_num = 0;
	for(int i = 0; i < N; ++i) {
		if(S[i] == '1') S_num |= 1 << i;
	}
	
	if(!(K&1)) {
		puts("-1");
		return 0;
	}
	
	int M = 1 << K + 1;
	
	f[0] = 0;
	f[1] = 1;
	for(int p = 2; p < M; p <<= 1) {
		for(int i = 0; i < p; ++i) {
			f[p + i] = f[p - i - 1] | p;
		}
	}
	
	for(int i = 1; i < M; i += 2) {
		f[i] = f[i] ^ (M - 1);
	}
	
	for(int p = M; p < 1 << N; p <<= 1) {
		for(int i = 0; i < p; ++i) {
			f[p + i] = f[p - i - 1] ^ (M - 1) | p;
		}
	}
	
	int S_pos = 0;
	while(f[S_pos] != S_num) {
		++S_pos;
	}
	
	for(int i = 0; i < 1 << N; ++i) {
		int X = f[S_pos + i & (1 << N) - 1];
		for(int j = 0; j < N; ++j) {
			printf("%d", (X >> j) & 1);
		}
		printf("\n");
	}
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:25:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   25 |  int M = 1 << K + 1;
      |               ~~^~~
lyuboyn.cpp:41:28: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
   41 |    f[p + i] = f[p - i - 1] ^ (M - 1) | p;
      |               ~~~~~~~~~~~~~^~~~~~~~~
lyuboyn.cpp:51:19: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   51 |   int X = f[S_pos + i & (1 << N) - 1];
      |             ~~~~~~^~~
lyuboyn.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d%d", &N, &K, &T);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%s", S);
      |  ~~~~~^~~~~~~~~
# 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 0 ms 292 KB Expected integer, but "0000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Ok
2 Correct 0 ms 288 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 1 ms 212 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 328 ms 6316 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 326 ms 6252 KB Expected integer, but "010101010011010100" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 328 ms 6316 KB Expected integer, but "000000000000000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 3148 KB Expected integer, but "01011001010101101" found
2 Halted 0 ms 0 KB -