답안 #339464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339464 2020-12-25T10:44:47 Z mosiashvililuka "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
651 ms 7660 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,n,k,T,p[1000009],pi,q[1000009],qi,z,x,y;
string ss;
string totwo(int q){
	//cout<<q<<" l"<<endl;
	string s;
	for(int h=n-1; h>=0; h--){
		if(((1<<h)&q)!=0) s.push_back('1'); else s.push_back('0');
	}
	return s;
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>k>>T>>ss;
	if(k%2==0){
		cout<<-1;
		return 0;
	}
	if(k>=n){
		cout<<-1;
		return 0;
	}
	pi=4;
	p[1]=0;p[2]=1;p[3]=3;p[4]=2;
	for(i=4; i<=k+1; i+=2){
		qi=0;
		y=(1<<(i-2))-1;z=(1<<(i-1));x=(1<<(i-2));
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];
			if(j%2==0){
				q[qi]^=z;q[qi]^=x;
			}
		}
		c=(p[pi]^y);
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];q[qi]^=c;
			if(j%2==1){
				q[qi]^=x;
			}else{
				q[qi]^=z;
			}
		}
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];
			if(j%2==1){
				q[qi]^=z;q[qi]^=x;
			}
		}
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];q[qi]^=c;
			if(j%2==1){
				q[qi]^=z;
			}else{
				q[qi]^=x;
			}
		}
		pi=qi;
		for(j=1; j<=pi; j++) p[j]=q[j];
	}
	for(i=k+2; i<=n; i++){
		qi=0;y=(1<<(k-1))-1;z=(1<<(i-1));
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];
		}
		y^=q[qi];
		for(j=1; j<=pi; j++){
			qi++;q[qi]=p[j];q[qi]^=y;q[qi]^=z;
		}
		pi=qi;
		for(j=1; j<=pi; j++) p[j]=q[j];
	}
	c=0;
	for(i=0; i<n; i++) if(ss[i]=='1') c+=(1<<(n-i-1));
	for(i=1; i<=pi; i++) p[i]^=c;
	cout<<pi<<endl;
	for(i=1; i<=pi; i++){
		cout<<totwo(p[i])<<endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 625 ms 7404 KB Ok
2 Correct 322 ms 3820 KB Ok
3 Correct 3 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 400 KB Ok
2 Correct 19 ms 492 KB Ok
3 Correct 315 ms 3820 KB Ok
4 Correct 159 ms 2156 KB Ok
5 Correct 2 ms 364 KB Ok
6 Correct 6 ms 364 KB Ok
7 Correct 75 ms 1132 KB Ok
8 Correct 1 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 625 ms 7472 KB Ok
2 Correct 617 ms 7532 KB Ok
3 Correct 651 ms 7560 KB Ok
4 Correct 311 ms 3820 KB Ok
5 Correct 335 ms 3820 KB Ok
6 Correct 152 ms 2028 KB Ok
7 Correct 152 ms 2028 KB Ok
8 Correct 76 ms 1132 KB Ok
9 Correct 76 ms 1132 KB Ok
10 Correct 38 ms 748 KB Ok
11 Correct 3 ms 364 KB Ok
12 Correct 3 ms 364 KB Ok
13 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 625 ms 7404 KB Ok
2 Correct 322 ms 3820 KB Ok
3 Correct 3 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 400 KB Ok
7 Correct 19 ms 492 KB Ok
8 Correct 315 ms 3820 KB Ok
9 Correct 159 ms 2156 KB Ok
10 Correct 2 ms 364 KB Ok
11 Correct 6 ms 364 KB Ok
12 Correct 75 ms 1132 KB Ok
13 Correct 1 ms 376 KB Ok
14 Correct 625 ms 7472 KB Ok
15 Correct 617 ms 7532 KB Ok
16 Correct 651 ms 7560 KB Ok
17 Correct 311 ms 3820 KB Ok
18 Correct 335 ms 3820 KB Ok
19 Correct 152 ms 2028 KB Ok
20 Correct 152 ms 2028 KB Ok
21 Correct 76 ms 1132 KB Ok
22 Correct 76 ms 1132 KB Ok
23 Correct 38 ms 748 KB Ok
24 Correct 3 ms 364 KB Ok
25 Correct 3 ms 364 KB Ok
26 Correct 1 ms 364 KB Ok
27 Correct 617 ms 7444 KB Ok
28 Correct 308 ms 3748 KB Ok
29 Correct 607 ms 7660 KB Ok
30 Correct 37 ms 748 KB Ok
31 Correct 3 ms 364 KB Ok
32 Correct 19 ms 492 KB Ok
33 Correct 75 ms 1260 KB Ok
34 Correct 1 ms 364 KB Ok
35 Correct 1 ms 364 KB Ok
36 Correct 2 ms 364 KB Ok
37 Correct 1 ms 364 KB Ok
38 Correct 305 ms 3820 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 3856 KB Ok
2 Correct 618 ms 7660 KB Ok
3 Correct 623 ms 7612 KB Ok
4 Correct 38 ms 748 KB Ok
5 Correct 2 ms 364 KB Ok
6 Correct 76 ms 1132 KB Ok
7 Correct 631 ms 7532 KB Ok
8 Correct 3 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 3 ms 364 KB Ok
11 Correct 155 ms 2028 KB Ok
12 Correct 313 ms 3820 KB Ok