Submission #305710

# Submission time Handle Problem Language Result Execution time Memory
305710 2020-09-23T20:47:25 Z fishy15 "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
276 ms 6700 KB
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

#define ll long long
#define ld long double
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 1000000

using namespace std;

int n, k, t;
string s;
int start;

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> k >> t;
    cin >> s;
    for (int i = 0; i < n; i++) {
        start += (1 << i) * (s[n - i - 1] - '0');
    }

    if (k % 2 == 0 || (n > 1 && k >= n)) {
        cout << "-1\n";
        return 0;
    }

    vector<int> ans = {0, 1};
    for (int i = 1; i < n; i++) {
        int num = 1 << i;
        if (i > k) {
            num += (1 << (k - 1)) - 1;
        }
        for (int j = (1 << i) - 1; j >= 0; j--) {
            ans.push_back(ans[j] ^ num);
        }
        if (i == k) {
            for (int j = 0; j < (1 << i); j++) {
                ans[2 * j + 1] ^= (1 << (i + 1)) - 1; 
            }
        }
    }

    rotate(ans.begin(), find(ans.begin(), ans.end(), start), ans.end());

    cout << (1 << n) << '\n';
    for (int i : ans) {
        for (int j = n - 1; j >= 0; j--) {
            cout << ((i & (1 << j)) > 0);
        }
        cout << '\n';
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Ok
2 Correct 0 ms 384 KB Ok
3 Correct 0 ms 384 KB Ok
4 Correct 0 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
6 Correct 0 ms 384 KB Ok
7 Correct 0 ms 384 KB Ok
8 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 269 ms 6512 KB Ok
2 Correct 126 ms 3444 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 1 ms 512 KB Ok
5 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Ok
2 Correct 7 ms 512 KB Ok
3 Correct 129 ms 3316 KB Ok
4 Correct 59 ms 1912 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 2 ms 384 KB Ok
7 Correct 29 ms 1280 KB Ok
8 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 270 ms 6540 KB Ok
2 Correct 268 ms 6512 KB Ok
3 Correct 266 ms 6616 KB Ok
4 Correct 127 ms 3316 KB Ok
5 Correct 130 ms 3316 KB Ok
6 Correct 61 ms 1912 KB Ok
7 Correct 60 ms 1912 KB Ok
8 Correct 30 ms 1148 KB Ok
9 Correct 31 ms 1152 KB Ok
10 Correct 15 ms 768 KB Ok
11 Correct 1 ms 384 KB Ok
12 Correct 2 ms 384 KB Ok
13 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 269 ms 6512 KB Ok
2 Correct 126 ms 3444 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 1 ms 512 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 1 ms 384 KB Ok
7 Correct 7 ms 512 KB Ok
8 Correct 129 ms 3316 KB Ok
9 Correct 59 ms 1912 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 29 ms 1280 KB Ok
13 Correct 1 ms 384 KB Ok
14 Correct 270 ms 6540 KB Ok
15 Correct 268 ms 6512 KB Ok
16 Correct 266 ms 6616 KB Ok
17 Correct 127 ms 3316 KB Ok
18 Correct 130 ms 3316 KB Ok
19 Correct 61 ms 1912 KB Ok
20 Correct 60 ms 1912 KB Ok
21 Correct 30 ms 1148 KB Ok
22 Correct 31 ms 1152 KB Ok
23 Correct 15 ms 768 KB Ok
24 Correct 1 ms 384 KB Ok
25 Correct 2 ms 384 KB Ok
26 Correct 1 ms 384 KB Ok
27 Correct 272 ms 6700 KB Ok
28 Correct 131 ms 3320 KB Ok
29 Correct 271 ms 6508 KB Ok
30 Correct 14 ms 768 KB Ok
31 Correct 1 ms 384 KB Ok
32 Correct 7 ms 512 KB Ok
33 Correct 29 ms 1152 KB Ok
34 Correct 1 ms 384 KB Ok
35 Correct 1 ms 384 KB Ok
36 Correct 1 ms 384 KB Ok
37 Correct 0 ms 384 KB Ok
38 Correct 128 ms 3388 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 127 ms 3312 KB Ok
2 Correct 276 ms 6512 KB Ok
3 Correct 270 ms 6508 KB Ok
4 Correct 14 ms 768 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 29 ms 1152 KB Ok
7 Correct 267 ms 6512 KB Ok
8 Correct 1 ms 384 KB Ok
9 Correct 1 ms 384 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 61 ms 1912 KB Ok
12 Correct 128 ms 3316 KB Ok