#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define mod 1000000007
#define sp << " " <<
#define endl << '\n'
long long int N, K, T;
vector<long long int> out;
long long int shifter(int n){
if (N % K == 0){
if (n == N - 1)
return (1 << (K - 1)) - 1 + (1 << (N - 1));
long long int temp = (1 << n) * ((1 << K) - 1);
return temp % (1 << (N - 1)) + temp / (1 << (N - 1));
}
long long int temp = (1 << n) * ((1 << K) - 1);
return temp % (1 << N) + temp / (1 << N);
}
void dp(long long int say, int n=0, bool mirored=false){
if (n == N){
out.push_back(say);
return;
}
if (mirored){
dp(say ^ shifter(n), n + 1, false);
dp(say, n + 1, true);
}else{
dp(say, n + 1, false);
dp(say ^ shifter(n), n + 1, true);
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N >> K >> T;
long long int S = 0;
for (int i = 0; i < N; i++){
char k;
cin >> k;
S += (k == '1') * (1 << i);
}
dp(S);
vector<int> table(1 << N);
for (int i : out){
if (table[i]){
cout << -1;
return 0;
}
table[i]++;
}
cout << (1 << N) endl;
for (int i : out){
for (int o = 0; o < N; o++){
if (i & (1 << o)){
cout << 1;
}else{
cout << 0;
}
}
cout endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |