Submission #911234

# Submission time Handle Problem Language Result Execution time Memory
911234 2024-01-18T16:35:50 Z daoquanglinh2007 "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
169 ms 6604 KB
#include <bits/stdc++.h>
using namespace std;

string bS;
int N, K, S, T;
vector <int> v, ans;

vector <int> build(int N){
	if (N == 1){
		vector <int> ans = {0, 1};
		return ans;
	}
	vector <int> a = build(N-1);
	for (int i = 0; i < (1<<(N-1)); i++){
		a.push_back((1<<(N-1))+a[(1<<(N-1))-1-i]);
	}
	return a;
}

vector <int> solve(int N, int K){
	if (K%2 == 0) return {};
	if (K == 1) return build(N);
	vector <int> tmp = solve(N-2, K-2), ans(0);
	for (int i = 0; i < (1<<(N-2)); i++){
		if (i&1) ans.push_back((tmp[i]<<2)+3);
		else ans.push_back(tmp[i]<<2);
	}
	for (int i = 0; i < (1<<(N-2)); i++){
		if (i&1) ans.push_back(((tmp[i]<<2)^4)+1);
		else ans.push_back(((tmp[i]<<2)^4)+2);
	}
	for (int i = 0; i < (1<<(N-2)); i++){
		if (i&1) ans.push_back(tmp[i]<<2);
		else ans.push_back((tmp[i]<<2)+3);
	}
	for (int i = 0; i < (1<<(N-2)); i++){
		if (i&1) ans.push_back(((tmp[i]<<2)^4)+2);
		else ans.push_back(((tmp[i]<<2)^4)+1);
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N >> K >> T >> bS;
	for (int i = 0; i < N; i++)
		if (bS[i] == '1') S += (1<<(N-1-i));
		
	vector <int> ans = solve(N, K);
	if (ans.empty()){
		cout << "-1\n";
		return 0;
	}
	cout << (1<<N) << '\n';
	for (int &x : ans){
		x ^= S;
		for (int i = N-1; i >= 0; i--)
			cout << ((x>>i)&1);
		cout << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
# Verdict Execution time Memory 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 1 ms 348 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 1 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 167 ms 6604 KB Ok
2 Correct 80 ms 3280 KB Ok
3 Correct 1 ms 344 KB Ok
4 Correct 0 ms 344 KB Ok
5 Correct 1 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 4 ms 604 KB Ok
3 Correct 74 ms 3412 KB Ok
4 Correct 38 ms 1948 KB Ok
5 Correct 1 ms 344 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 17 ms 1136 KB Ok
8 Correct 1 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 161 ms 6392 KB Ok
2 Correct 160 ms 6576 KB Ok
3 Correct 160 ms 6604 KB Ok
4 Correct 77 ms 3364 KB Ok
5 Correct 76 ms 3536 KB Ok
6 Correct 37 ms 1920 KB Ok
7 Correct 36 ms 1760 KB Ok
8 Correct 17 ms 1116 KB Ok
9 Correct 18 ms 1072 KB Ok
10 Correct 9 ms 660 KB Ok
11 Correct 1 ms 504 KB Ok
12 Correct 1 ms 348 KB Ok
13 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 167 ms 6604 KB Ok
2 Correct 80 ms 3280 KB Ok
3 Correct 1 ms 344 KB Ok
4 Correct 0 ms 344 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 344 KB Ok
7 Correct 4 ms 604 KB Ok
8 Correct 74 ms 3412 KB Ok
9 Correct 38 ms 1948 KB Ok
10 Correct 1 ms 344 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 17 ms 1136 KB Ok
13 Correct 1 ms 348 KB Ok
14 Correct 161 ms 6392 KB Ok
15 Correct 160 ms 6576 KB Ok
16 Correct 160 ms 6604 KB Ok
17 Correct 77 ms 3364 KB Ok
18 Correct 76 ms 3536 KB Ok
19 Correct 37 ms 1920 KB Ok
20 Correct 36 ms 1760 KB Ok
21 Correct 17 ms 1116 KB Ok
22 Correct 18 ms 1072 KB Ok
23 Correct 9 ms 660 KB Ok
24 Correct 1 ms 504 KB Ok
25 Correct 1 ms 348 KB Ok
26 Correct 0 ms 348 KB Ok
27 Correct 167 ms 6388 KB Ok
28 Correct 78 ms 3472 KB Ok
29 Correct 164 ms 6388 KB Ok
30 Correct 9 ms 600 KB Ok
31 Correct 2 ms 348 KB Ok
32 Correct 4 ms 604 KB Ok
33 Correct 22 ms 1068 KB Ok
34 Correct 1 ms 344 KB Ok
35 Correct 0 ms 348 KB Ok
36 Correct 1 ms 348 KB Ok
37 Correct 0 ms 348 KB Ok
38 Correct 77 ms 3352 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 79 ms 3336 KB Ok
2 Correct 169 ms 6596 KB Ok
3 Correct 160 ms 6396 KB Ok
4 Correct 9 ms 600 KB Ok
5 Correct 1 ms 344 KB Ok
6 Correct 22 ms 1080 KB Ok
7 Correct 159 ms 6592 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 1 ms 348 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 38 ms 1916 KB Ok
12 Correct 80 ms 3352 KB Ok