답안 #290958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290958 2020-09-04T15:04:57 Z Plurm "The Lyuboyn" code (IZhO19_lyuboyn) C++11
100 / 100
312 ms 35192 KB
#include <bits/stdc++.h>
using namespace std;
int lsb[300005];
int rmp[300005];
int seq[300005];
set<string> s;
int main(){
	int n,k,t;
	scanf("%d%d%d",&n,&k,&t);
	if(k % 2 == 0 || k >= n){
		printf("-1\n");
		return 0;
	}
	for(int i = 0; i <= 18; i++) rmp[1 << i] = i;
	for(int i = 0; i < (1 << n); i += 2){
		int lsb1 = rmp[i+1 & -(i+1)];
		int lsb2 = rmp[i+2 & -(i+2)];
		int c = 1;
		for(int j = 0; j < n; j++){
			if(j != lsb1 && j != lsb2 && c < k){
				c++;
				seq[i] |= 1 << j;
			}
		}
		seq[i+1] = seq[i];
	}
	printf("%d\n", 1 << n);
	char bs[32];
	scanf("%s",bs);
	if(strlen(bs) != n) while(true);
	int parsed = 0;
	for(int i = 0; i < n; i++){
		parsed *= 2;
		parsed += bs[i] == '1' ? 1 : 0;
	}
	printf("%s\n",bs);
	s.insert(bs);
	for(int i = 1; i < (1 << n); i++){
		int bit = rmp[i & -i];
		int toggidx = bit;
		toggidx = n-toggidx-1;
		bs[toggidx] = '0'+'1'-bs[toggidx];
		for(int j = 0; j < n; j++){
			if(seq[i-1] & (1 << j)) bs[n-j-1] = '0'+'1'-bs[n-j-1];
		}
		if(s.count(bs)) while(true);
		s.insert(bs);
		printf("%s\n",bs);
	}
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:16:19: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   16 |   int lsb1 = rmp[i+1 & -(i+1)];
      |                  ~^~
lyuboyn.cpp:17:19: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   17 |   int lsb2 = rmp[i+2 & -(i+2)];
      |                  ~^~
lyuboyn.cpp:30:16: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |  if(strlen(bs) != n) while(true);
      |     ~~~~~~~~~~~^~~~
lyuboyn.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d%d%d",&n,&k,&t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf("%s",bs);
      |  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Ok
2 Correct 0 ms 256 KB Ok
3 Correct 0 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 0 ms 256 KB Ok
6 Correct 1 ms 256 KB Ok
7 Correct 0 ms 256 KB Ok
8 Correct 0 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 35192 KB Ok
2 Correct 141 ms 17656 KB Ok
3 Correct 1 ms 512 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Ok
2 Correct 7 ms 1152 KB Ok
3 Correct 131 ms 17656 KB Ok
4 Correct 81 ms 8952 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 2 ms 512 KB Ok
7 Correct 27 ms 3584 KB Ok
8 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 35192 KB Ok
2 Correct 278 ms 35064 KB Ok
3 Correct 281 ms 35064 KB Ok
4 Correct 137 ms 17644 KB Ok
5 Correct 138 ms 17656 KB Ok
6 Correct 67 ms 9080 KB Ok
7 Correct 64 ms 8952 KB Ok
8 Correct 28 ms 3584 KB Ok
9 Correct 29 ms 3584 KB Ok
10 Correct 14 ms 1920 KB Ok
11 Correct 1 ms 512 KB Ok
12 Correct 1 ms 512 KB Ok
13 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 35192 KB Ok
2 Correct 141 ms 17656 KB Ok
3 Correct 1 ms 512 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 1 ms 384 KB Ok
7 Correct 7 ms 1152 KB Ok
8 Correct 131 ms 17656 KB Ok
9 Correct 81 ms 8952 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 2 ms 512 KB Ok
12 Correct 27 ms 3584 KB Ok
13 Correct 1 ms 384 KB Ok
14 Correct 308 ms 35192 KB Ok
15 Correct 278 ms 35064 KB Ok
16 Correct 281 ms 35064 KB Ok
17 Correct 137 ms 17644 KB Ok
18 Correct 138 ms 17656 KB Ok
19 Correct 67 ms 9080 KB Ok
20 Correct 64 ms 8952 KB Ok
21 Correct 28 ms 3584 KB Ok
22 Correct 29 ms 3584 KB Ok
23 Correct 14 ms 1920 KB Ok
24 Correct 1 ms 512 KB Ok
25 Correct 1 ms 512 KB Ok
26 Correct 1 ms 384 KB Ok
27 Correct 298 ms 35064 KB Ok
28 Correct 139 ms 17680 KB Ok
29 Correct 312 ms 35192 KB Ok
30 Correct 14 ms 1920 KB Ok
31 Correct 1 ms 512 KB Ok
32 Correct 7 ms 1152 KB Ok
33 Correct 29 ms 3584 KB Ok
34 Correct 1 ms 384 KB Ok
35 Correct 1 ms 384 KB Ok
36 Correct 1 ms 384 KB Ok
37 Correct 1 ms 384 KB Ok
38 Correct 143 ms 17656 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 17656 KB Ok
2 Correct 286 ms 35064 KB Ok
3 Correct 288 ms 35068 KB Ok
4 Correct 14 ms 1920 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 27 ms 3576 KB Ok
7 Correct 292 ms 35168 KB Ok
8 Correct 1 ms 512 KB Ok
9 Correct 0 ms 384 KB Ok
10 Correct 1 ms 512 KB Ok
11 Correct 68 ms 8952 KB Ok
12 Correct 146 ms 17656 KB Ok