#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
//#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define prc(n) fixed << setprecision(n)
#define fastios ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi acos(-1);
const int inf = 1e9+7;
const int N = 105;
int n, m, t, a;
string bin(int a){
string s;
while(a){
s.pb(char((a%2) + '0'));
a/=2;
}
while(sz(s) < n) s.pb('0');
reverse(all(s));
return s;
}
map<int, int> mp;
void rec(vector<int> order, int last){
if(last == (1<<n)){
if(t && __builtin_popcount(order[0] ^ order[last-1]) != m) return;
cout<<(1<<n)<<"\n";
for(int i=0;i<(1<<n);i++){
cout<<bin(order[i])<<"\n";
}
exit(0);
}
for(int i=0;i<(1<<n);i++){
if(mp[i] == 0){
//cout<<i<<"\n";
bool ok = 1;
if(__builtin_popcount(order[last-1] ^ i) != m) ok = 0;
//cout<<__builtin_popcount(order[last-1] ^ i)<<" "<<order[last-1]<<" "<<i<<"\n";
if(ok){
mp[i] = 1;
order.pb(i);
rec(order, last+1);
order.pop_back();
mp[i] = 0;
}
}
}
}
int main(){
cin>>n>>m>>t;
if(m%2 == 0){
cout<<-1;
return 0;
}
string s;
cin>>s;
reverse(all(s));
for(int i=0;i<sz(s);i++)
if(s[i] == '1') a += (1<<i);
mp[a] = 1;
rec({a}, 1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
2 |
Correct |
1 ms |
364 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
268 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
0 ms |
364 KB |
Ok |
8 |
Correct |
0 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
121524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
2 |
Execution timed out |
1102 ms |
126828 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
122636 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1098 ms |
121524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1091 ms |
4192 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |