This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* 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){
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{
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 (stderr)
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:36:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i = 0; i < v.size(); ++i){
| ~~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:57:15: warning: unused variable 'aa' [-Wunused-variable]
57 | int tt = 1, aa;
| ^~
# | 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... |