답안 #948455

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948455 2024-03-18T06:27:32 Z willychan "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
177 ms 6808 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds

vector<int> get(int n,int k){
	assert(k%2);
	assert(k<n);
	vector<int> ans;	
	if(k==1){
		if(n==2){
			ans.push_back(0);
			ans.push_back(1);
			ans.push_back(3);
			ans.push_back(2);
			return ans;
		}
		vector<int> g = get(n-1,k);
		for(int j=0;j<(int)g.size();j++){
			bool f = j&1;
			ans.push_back((f*(1<<(n-1)))+g[j]);
			ans.push_back(((!f)*(1<<(n-1)))+g[j]);
		}
		return ans;
	}
	if(k+1==n){
		ans = get(n,1);
		int b = 0;
		for(int i=0;i<n;i++) b+=(1<<i);
		for(int i=0;i<(int)ans.size();i++){
			if(i&1) ans[i]^=b;
		}
		return ans;
	}
	vector<int> g = get(n-1,k);
	int b = (g.back()&(-g.back()));
	b = g.back()-b;
	b+=(1<<(n-1));
	for(auto i : g) ans.push_back(i);
	reverse(g.begin(),g.end());
	for(auto i : g) ans.push_back(i^b);
	return ans;
}
int n,k,t;
int to_num(string &a){
	int r = 0;
	for(int i=0;i<n;i++) r^=((1<<i)*(a[i]=='1'));
	return r;
}

void print(int a,int f){
	for(int i=0;i<f;i++) cout<<((a>>i)&1);
	cout<<"\n";
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>k>>t;
	string s;cin>>s;
	if(k%2==0){
		cout<<"-1\n";
		return 0;
	}
	int b = to_num(s);
	vector<int> ans = get(n,k);
	cout<<(1<<n)<<"\n";
	for(auto i : ans) print(i^b,n);
	sort(ans.begin(),ans.end());
	assert(unique(ans.begin(),ans.end())-ans.begin()==(1<<n));

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 6432 KB Ok
2 Correct 80 ms 3248 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 1 ms 452 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
2 Correct 5 ms 604 KB Ok
3 Correct 125 ms 3364 KB Ok
4 Correct 37 ms 1752 KB Ok
5 Correct 1 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 18 ms 1232 KB Ok
8 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 6800 KB Ok
2 Correct 166 ms 6572 KB Ok
3 Correct 168 ms 6504 KB Ok
4 Correct 80 ms 3240 KB Ok
5 Correct 81 ms 3392 KB Ok
6 Correct 38 ms 1744 KB Ok
7 Correct 38 ms 1740 KB Ok
8 Correct 18 ms 1248 KB Ok
9 Correct 18 ms 1248 KB Ok
10 Correct 9 ms 860 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 348 KB Ok
13 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 6432 KB Ok
2 Correct 80 ms 3248 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 1 ms 452 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 5 ms 604 KB Ok
8 Correct 125 ms 3364 KB Ok
9 Correct 37 ms 1752 KB Ok
10 Correct 1 ms 344 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 18 ms 1232 KB Ok
13 Correct 0 ms 348 KB Ok
14 Correct 167 ms 6800 KB Ok
15 Correct 166 ms 6572 KB Ok
16 Correct 168 ms 6504 KB Ok
17 Correct 80 ms 3240 KB Ok
18 Correct 81 ms 3392 KB Ok
19 Correct 38 ms 1744 KB Ok
20 Correct 38 ms 1740 KB Ok
21 Correct 18 ms 1248 KB Ok
22 Correct 18 ms 1248 KB Ok
23 Correct 9 ms 860 KB Ok
24 Correct 1 ms 348 KB Ok
25 Correct 1 ms 348 KB Ok
26 Correct 0 ms 348 KB Ok
27 Correct 170 ms 6420 KB Ok
28 Correct 83 ms 3396 KB Ok
29 Correct 169 ms 6540 KB Ok
30 Correct 9 ms 860 KB Ok
31 Correct 1 ms 348 KB Ok
32 Correct 4 ms 604 KB Ok
33 Correct 18 ms 1248 KB Ok
34 Correct 1 ms 348 KB Ok
35 Correct 1 ms 512 KB Ok
36 Correct 0 ms 348 KB Ok
37 Correct 0 ms 348 KB Ok
38 Correct 80 ms 3400 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 3392 KB Ok
2 Correct 177 ms 6808 KB Ok
3 Correct 169 ms 6580 KB Ok
4 Correct 9 ms 860 KB Ok
5 Correct 1 ms 344 KB Ok
6 Correct 29 ms 1248 KB Ok
7 Correct 165 ms 6572 KB Ok
8 Correct 1 ms 348 KB Ok
9 Correct 0 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 51 ms 1772 KB Ok
12 Correct 81 ms 3400 KB Ok