/* 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;
bitset<18> b;
for(int i = 0; i< n; ++i){
char c; cin >> c;
b[i] = c == '1';
}
vector<int> v;
for(int i = 0; i < (1<<n); ++i){
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)^b[j]);
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)^b[j]);
en;
}
return;
}
}
}while(next_permutation(all(v)));
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:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i = 1; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp:29:26: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
29 | if((b1^b2).count() != k){ok = 0; break;}
| ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:35:28: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | if((b1^b2).count() == k){
| ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:37:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:59:15: warning: unused variable 'aa' [-Wunused-variable]
59 | int tt = 1, aa;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
First number in answer is not x 1 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
344 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
1500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1053 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1064 ms |
1500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
1500 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1010 ms |
988 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |