/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 40, K = 52, MX = 30;
int n, k, t;
void solve(){
cin >> n >> k >> t;
int s = 0;
for(int i = n-1; i >= 0; --i){
char c; cin >> c;
s += (1<<i)*(c=='1');
}
vector<int> v;
v.pb(s);
for(int i = 0; i < (1<<n); ++i){
if(i!=s) v.pb(i);
}
do{
bool ok = 1;
for(int i = 1; i < v.size(); ++i){
bitset<18> b1(v[i-1]);
bitset<18> b2(v[i]);
if((b1^b2).count() != k){ok = 0; break;}
}
if(ok){
if(t){
bitset<18> b1(v[0]);
bitset<18> b2(v.back());
if((b1^b2).count() == k){
cout << (1<<n) << '\n';
for(int i = 0; i < v.size(); ++i){
for(int j = n-1; j >= 0; --j) cout << (((1<<j)&v[i])>0);
en;
}
return;
}
} else{
cout << (1<<n) << '\n';
for(int i = 0; i < v.size(); ++i){
for(int j = n-1; j >= 0; --j) cout << (((1<<j)&v[i])>0);
en;
}
return;
}
}
}while(next_permutation(v.begin()+1, v.end()));
cout << -1;
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
int tt = 1, aa;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
while(tt--){
solve();
en;
}
cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
return 0;
}
Compilation message
lyuboyn.cpp: In function 'void solve()':
lyuboyn.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for(int i = 1; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp:30:26: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
30 | if((b1^b2).count() != k){ok = 0; break;}
| ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:36:28: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if((b1^b2).count() == k){
| ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:38:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp:46:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:60:15: warning: unused variable 'aa' [-Wunused-variable]
60 | int tt = 1, aa;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1059 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1025 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
1500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1022 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1012 ms |
1496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1052 ms |
1500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1050 ms |
992 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |