답안 #636795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636795 2022-08-30T08:40:38 Z valerikk "The Lyuboyn" code (IZhO19_lyuboyn) C++17
8 / 100
393 ms 6240 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;
	}
	
	printf("%d\n", 1 << N);
	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:52:19: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   52 |   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);
      |  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Ok
2 Correct 0 ms 212 KB Ok
3 Correct 1 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 1 ms 212 KB Ok
8 Correct 0 ms 212 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 393 ms 6240 KB Fail, not exactly k bits are different: line = 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Fail, not exactly k bits are different: line = 15
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 392 ms 6204 KB Fail, not exactly k bits are different: line = 51
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 393 ms 6240 KB Fail, not exactly k bits are different: line = 3
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 174 ms 3144 KB Fail, not exactly k bits are different: line = 58950
2 Halted 0 ms 0 KB -