# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169488 | 2019-12-20T16:40:40 Z | SamAnd | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 118 ms | 7112 KB |
#include <bits/stdc++.h> using namespace std; const int N = 20; int n, k, tt; char s[N]; int main() { //freopen("input.txt", "r", stdin); scanf("%d%d%d", &n, &k, &tt); scanf(" %s", s); if (k % 2 == 0) { printf("-1\n"); return 0; } int x = 0; for (int i = 0; i < n; ++i) { if (s[i] == '1') x |= (1 << i); } vector<int> v, vv; v.push_back(0); v.push_back(1); for (int i = 1; i < (k + 1); ++i) { vv = v; v = vv; reverse(vv.begin(), vv.end()); for (int j = 0; j < vv.size(); ++j) v.push_back((vv[j] | (1 << i))); } /*for (int i = 0; i < v.size(); ++i) { for (int j = 0; j < (k + 1); ++j) { if ((v[i] & (1 << j))) putchar('1'); else putchar('0'); } putchar('\n'); }*/ vv.clear(); vv.push_back(0); for (int i = 1; i < v.size(); ++i) { int x = 0; for (int j = 0; j < (k + 1); ++j) { if (((v[i] & (1 << j)) && (v[i - 1] & (1 << j))) || (!(v[i] & (1 << j)) && !(v[i - 1] & (1 << j)))) { if (!(vv[i - 1] & (1 << j))) x |= (1 << j); } else { if ((vv[i - 1] & (1 << j))) x |= (1 << j); } } vv.push_back(x); } v = vv; /*for (int i = 0; i < v.size(); ++i) { for (int j = 0; j < (k + 1); ++j) { if ((v[i] & (1 << j))) putchar('1'); else putchar('0'); } putchar('\n'); }*/ for (int i = (k + 1); i < n; ++i) { int x = 0; for (int j = i - 1; j >= i - k + 1; --j) x |= (1 << j); vv = v; reverse(vv.begin(), vv.end()); for (int j = 0; j < vv.size(); ++j) { v.push_back((vv[j] ^ x)); } } /*for (int i = 0; i < v.size(); ++i) { for (int j = 0; j < n; ++j) { if ((v[i] & (1 << j))) putchar('1'); else putchar('0'); } putchar('\n'); }*/ for (int i = 0; i < v.size(); ++i) v[i] ^= x; printf("%d\n", v.size()); for (int i = 0; i < v.size(); ++i) { for (int j = 0; j < n; ++j) { if ((v[i] & (1 << j))) putchar('1'); else putchar('0'); } putchar('\n'); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Ok |
2 | Correct | 2 ms | 376 KB | Ok |
3 | Correct | 2 ms | 256 KB | Ok |
4 | Correct | 2 ms | 376 KB | Ok |
5 | Correct | 2 ms | 376 KB | Ok |
6 | Correct | 2 ms | 380 KB | Ok |
7 | Correct | 2 ms | 256 KB | Ok |
8 | Correct | 2 ms | 376 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 103 ms | 7092 KB | The values in the output sequence are not pairwise distinct! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | The values in the output sequence are not pairwise distinct! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 118 ms | 7112 KB | The values in the output sequence are not pairwise distinct! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 103 ms | 7092 KB | The values in the output sequence are not pairwise distinct! |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 61 ms | 3772 KB | The values in the output sequence are not pairwise distinct! |
2 | Halted | 0 ms | 0 KB | - |