This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
typedef pair <int, int> pi;
typedef vector <int> vi;
int N, K, T;
string s;
void ispis (int x) {
for (int i = 0; i < N; i++) {
cout << !!(x & (1 << i));
}
cout << '\n';
}
vi gen (int n, int k) {
vi res;
if (k == 1) {
if (n == 1) {
res = {0, 1};
return res;
}
vi tmp = gen(n - 1, k);
for (int i = 0; i < tmp.size(); i++) {
res.push_back(tmp[i] * 2);
}
for (int i = (int) tmp.size() - 1; i >= 0; i--) {
res.push_back(tmp[i] * 2 + 1);
}
return res;
}
vi tmp = gen(n - 2, k - 2);
vi v[2];
v[0] = tmp; v[1] = tmp;
reverse(v[1].begin(), v[1].end());
for (int br = 0; br < 4; br++) {
int jen, dva;
if (br == 0) jen = 0, dva = 3;
if (br == 1) jen = 1, dva = 2;
if (br == 2) jen = 3, dva = 0;
if (br == 3) jen = 2, dva = 1;
int tip = br % 2;
for (int i = 0; i < v[tip].size(); i++) {
int val = v[tip][i];
if (br == 1 || br == 3) val ^= (1 << (k - 1)) - 1;
val *= 4;
if (i % 2 == 0) val += jen; else val += dva;
res.push_back(val);
}
}
return res;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K >> T >> s;
if (K % 2 == 0) {
cout << -1;
return 0;
}
int val = 0;
for (int i = 0; i < N; i++) {
if (s[i] == '1') val += 1 << i;
}
vi res = gen(N, K);
cout << (1 << N) << '\n';
for (auto x : res) ispis(x ^ val);
return 0;
}
Compilation message (stderr)
lyuboyn.cpp: In function 'vi gen(int, int)':
lyuboyn.cpp:27:27: 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 = 0; i < tmp.size(); i++) {
| ~~^~~~~~~~~~~~
lyuboyn.cpp:46:27: 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[tip].size(); i++) {
| ~~^~~~~~~~~~~~~~~
# | 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... |