#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 << endl;
}
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);
for (auto x : res) ispis(x ^ val);
return 0;
}
Compilation message
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 |
1 |
Incorrect |
1 ms |
364 KB |
The output is neither -1 nor the length of the answer |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "0000" found |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
841 ms |
6488 KB |
Expected integer, but "000000000000000000" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Expected integer, but "0000000" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
871 ms |
6784 KB |
Expected integer, but "010101010011010100" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
841 ms |
6488 KB |
Expected integer, but "000000000000000000" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
411 ms |
3536 KB |
Expected integer, but "01011001010101101" found |
2 |
Halted |
0 ms |
0 KB |
- |