Submission #332469

# Submission time Handle Problem Language Result Execution time Memory
332469 2020-12-02T16:18:05 Z keko37 "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
417 ms 6860 KB
#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

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 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 512 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 512 KB Ok
8 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 417 ms 6488 KB Ok
2 Correct 146 ms 3424 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 8 ms 492 KB Ok
3 Correct 141 ms 3552 KB Ok
4 Correct 73 ms 1804 KB Ok
5 Correct 2 ms 512 KB Ok
6 Correct 3 ms 364 KB Ok
7 Correct 32 ms 1152 KB Ok
8 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 305 ms 6528 KB Ok
2 Correct 322 ms 6860 KB Ok
3 Correct 315 ms 6484 KB Ok
4 Correct 146 ms 3572 KB Ok
5 Correct 148 ms 3448 KB Ok
6 Correct 82 ms 1940 KB Ok
7 Correct 68 ms 1896 KB Ok
8 Correct 33 ms 1152 KB Ok
9 Correct 32 ms 1156 KB Ok
10 Correct 20 ms 748 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 2 ms 364 KB Ok
13 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 417 ms 6488 KB Ok
2 Correct 146 ms 3424 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 8 ms 492 KB Ok
8 Correct 141 ms 3552 KB Ok
9 Correct 73 ms 1804 KB Ok
10 Correct 2 ms 512 KB Ok
11 Correct 3 ms 364 KB Ok
12 Correct 32 ms 1152 KB Ok
13 Correct 1 ms 364 KB Ok
14 Correct 305 ms 6528 KB Ok
15 Correct 322 ms 6860 KB Ok
16 Correct 315 ms 6484 KB Ok
17 Correct 146 ms 3572 KB Ok
18 Correct 148 ms 3448 KB Ok
19 Correct 82 ms 1940 KB Ok
20 Correct 68 ms 1896 KB Ok
21 Correct 33 ms 1152 KB Ok
22 Correct 32 ms 1156 KB Ok
23 Correct 20 ms 748 KB Ok
24 Correct 1 ms 364 KB Ok
25 Correct 2 ms 364 KB Ok
26 Correct 1 ms 364 KB Ok
27 Correct 314 ms 6544 KB Ok
28 Correct 155 ms 3532 KB Ok
29 Correct 309 ms 6536 KB Ok
30 Correct 17 ms 748 KB Ok
31 Correct 1 ms 364 KB Ok
32 Correct 7 ms 492 KB Ok
33 Correct 32 ms 1156 KB Ok
34 Correct 1 ms 364 KB Ok
35 Correct 1 ms 512 KB Ok
36 Correct 1 ms 364 KB Ok
37 Correct 1 ms 364 KB Ok
38 Correct 143 ms 3444 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 160 ms 3572 KB Ok
2 Correct 304 ms 6544 KB Ok
3 Correct 298 ms 6608 KB Ok
4 Correct 15 ms 748 KB Ok
5 Correct 1 ms 492 KB Ok
6 Correct 35 ms 1156 KB Ok
7 Correct 295 ms 6520 KB Ok
8 Correct 1 ms 492 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 70 ms 1816 KB Ok
12 Correct 158 ms 3444 KB Ok