#include <iostream>
#include <vector>//#include <bits/stdc++.h>
using namespace std;
vector<int> solve(int N, int K, int t){
if (K == N - 1){
vector<int> ans(1 << N);
ans[0] = t;
for (int i = 1; i < (1 << N); i++){
ans[i] = ans[i - 1] ^ ((1 << N) - 1);
int p = __builtin_ctz(i);
ans[i] ^= 1 << p;
}
return ans;
} else {
vector<int> P1 = solve(N - 1, K, t);
int r = P1.back();
int r2 = r ^ ((1 << (K - 1)) - 1);
vector<int> P2 = solve(N - 1, K, r2);
vector<int> P;
for (int i = 0; i < (1 << (N - 1)); i++){
P.push_back(P1[i]);
}
for (int i = 0; i < (1 << (N - 1)); i++){
P.push_back(P2[i] ^ (1 << (N - 1)));
}
return P;
}
}
int main(){
int N, K, T;
cin >> N >> K >> T;
string S;
cin >> S;
int s = 0;
for (int i = 0; i < N; i++){
if (S[i] == '1'){
s += 1 << (N - 1 - i);
}
}
if (N == 1){
cout << 2 << endl;
cout << s << endl;
cout << (s ^ 1) << endl;
} else if (K % 2 == 0 || N == K){
cout << -1 << endl;
} else {
vector<int> P = solve(N, K, 0);
for (int i = 0; i < (1 << N); i++){
if (P[i] == s){
rotate(P.begin(), P.begin() + i, P.end());
}
}
cout << (1 << N) << endl;
for (int i = 0; i < (1 << N); i++){
for (int j = N - 1; j >= 0; j--){
cout << (P[i] >> j & 1);
}
cout << endl;
}
}
}
Compilation message
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:50:9: error: 'rotate' was not declared in this scope
50 | rotate(P.begin(), P.begin() + i, P.end());
| ^~~~~~