// Knapsack DP is harder than FFT.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
#define ff first
#define ss second
#define pb emplace_back
#define FOR(i,n) for(int i = 0; i < (n); ++i)
#define FOO(i,a,b) for(int i = (a); i <= (b); ++i)
#define AI(x) (x).begin(),(x).end()
template<typename I> bool chmax(I &a, I b){ return a < b ? (a = b, true) : false;}
template<typename I> bool chmin(I &a, I b){ return a > b ? (a = b, true) : false;}
#ifdef OWO
#define debug(args...) LKJ("[ " + string(#args) + " ]", args)
void LKJ(){ cerr << endl;}
template<typename I, typename...T> void LKJ(I&&x, T&&...t){ cerr<<x<<", ", LKJ(t...);}
template<typename I> void DE(I a, I b){ while(a < b) cerr<<*a<<" \n"[next(a)==b], ++a;}
#else
#define debug(...) 0
#define DE(...) 0
#endif
int n, k, t, s;
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k >> t >> s;
if(k % 2 == 0 or k >= n){
puts("-1");
return 0;
}
if(k == 1 and s == 0){
vector<int> ans(2, 0);
ans[0] = 0, ans[1] = 1;
FOO(i,2,n){
vector<int> b = ans;
reverse(AI(b));
for(auto &j: b) j += (1<<(i-1));
for(auto j: b) ans.pb(j);
}
assert(ans.size() == (1<<n));
cout << ans.size() << '\n';
for(auto i: ans){
for(int j = n - 1; j >= 0; --j)
cout << ((i & (1<<j)) ? 1 : 0);
cout << '\n';
}
return 0;
}
if(k == 3 and s == 0){
n -= 2;
vector<int> ans(2, 0);
ans[0] = 0, ans[1] = 1;
FOO(i,2,n){
vector<int> b = ans;
reverse(AI(b));
for(auto &j: b) j += (1<<(i-1));
for(auto j: b) ans.pb(j);
}
assert(ans.size() == (1<<n));
cout << ans.size()*4 << '\n';
for(int x = 0; x < ans.size(); ++x){
int i = ans[x];
if(x & 1) i += 3 << n;
for(int j = n + 1; j >= 0; --j)
cout << ((i & (1<<j)) ? 1 : 0);
cout << '\n';
}
rotate(ans.begin(), ans.begin() + ans.size() / 2, ans.end());
for(int x = 0; x < ans.size(); ++x){
int i = ans[x];
i ^= 1 << n;
if(x & 1) i ^= 3 << n;
for(int j = n + 1; j >= 0; --j)
cout << ((i & (1<<j)) ? 1 : 0);
cout << '\n';
}
rotate(ans.begin(), ans.begin() + ans.size() / 2, ans.end());
for(int x = 0; x < ans.size(); ++x){
int i = ans[x];
i ^= 3 << n;
if(x & 1) i ^= 3 << n;
for(int j = n + 1; j >= 0; --j)
cout << ((i & (1<<j)) ? 1 : 0);
cout << '\n';
}
rotate(ans.begin(), ans.begin() + ans.size() / 2, ans.end());
for(int x = 0; x < ans.size(); ++x){
int i = ans[x];
i ^= 2 << n;
if(x & 1) i ^= 3 << n;
for(int j = n + 1; j >= 0; --j)
cout << ((i & (1<<j)) ? 1 : 0);
cout << '\n';
}
rotate(ans.begin(), ans.begin() + ans.size() / 2, ans.end());
return 0;
}
return 0;
}
Compilation message
In file included from /usr/include/c++/9/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:33,
from lyuboyn.cpp:2:
lyuboyn.cpp: In function 'int32_t main()':
lyuboyn.cpp:41:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | assert(ans.size() == (1<<n));
| ~~~~~~~~~~~^~~~~~~~~
lyuboyn.cpp:60:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
60 | assert(ans.size() == (1<<n));
| ~~~~~~~~~~~^~~~~~~~~
lyuboyn.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int x = 0; x < ans.size(); ++x){
| ~~^~~~~~~~~~~~
lyuboyn.cpp:71:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
71 | for(int x = 0; x < ans.size(); ++x){
| ~~^~~~~~~~~~~~
lyuboyn.cpp:80:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
80 | for(int x = 0; x < ans.size(); ++x){
| ~~^~~~~~~~~~~~
lyuboyn.cpp:89:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | for(int x = 0; x < ans.size(); ++x){
| ~~^~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Fail, not exactly k bits are different: line = 3 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
364 KB |
Ok |
6 |
Correct |
1 ms |
364 KB |
Ok |
7 |
Correct |
1 ms |
364 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
273 ms |
6492 KB |
Ok |
2 |
Correct |
151 ms |
3300 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Fail, not exactly k bits are different: line = 31 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
273 ms |
6492 KB |
Ok |
2 |
Correct |
151 ms |
3300 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Incorrect |
1 ms |
364 KB |
Fail, not exactly k bits are different: line = 31 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |