Submission #1090880

# Submission time Handle Problem Language Result Execution time Memory
1090880 2024-09-19T02:05:00 Z KKT89 "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
173 ms 32380 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k, t;
    cin >> n >> k >> t;
    if (k % 2 == 0) {
        cout << "-1" << endl;
        return 0;
    }
    string s;
    cin >> s;
    int init = 0;
    for (char c : s) {
        init = init * 2 + c - '0';
    }
    vector<int> v;
    vector<int> used(1 << n);
    used[init] = 1;
    vector<int> u;
    for (int i = 1; i < (1 << n); i++) {
        if (__builtin_popcount(i) == k) {
            u.push_back(i);
        }
    }
    auto dfs = [&](auto dfs) -> void {
        if (v.size() == (1 << n)) {
            if (__builtin_popcount(v[0] ^ v.back()) == k) {
                cout << v.size() << "\n";
                for (int i : v) {
                    for (int j = n - 1; j >= 0; --j) {
                        if ((1 << j) & i) cout << 1;
                        else cout << 0;
                    }
                    cout << "\n";
                }
                cout << endl;
                exit(0);
            }
            return;
        }
        for (int i : u) {
            int nx = (v.back() ^ i);
            if (used[nx]) continue;
            v.push_back(nx);
            used[nx] = 1;
            dfs(dfs);
            used[nx] = 0;
            v.pop_back();
        }
    };
    v.push_back(init);
    dfs(dfs);
}

Compilation message

lyuboyn.cpp: In instantiation of 'main()::<lambda(auto:23)> [with auto:23 = main()::<lambda(auto:23)>]':
lyuboyn.cpp:61:12:   required from here
lyuboyn.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         if (v.size() == (1 << n)) {
      |             ~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 348 KB Ok
8 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 152 ms 32084 KB Ok
2 Correct 73 ms 16080 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 4 ms 1232 KB Ok
3 Correct 78 ms 16080 KB Ok
4 Correct 35 ms 8280 KB Ok
5 Correct 1 ms 344 KB Ok
6 Correct 1 ms 604 KB Ok
7 Correct 17 ms 4276 KB Ok
8 Correct 1 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 157 ms 32356 KB Ok
2 Correct 157 ms 32092 KB Ok
3 Correct 151 ms 32204 KB Ok
4 Correct 75 ms 16328 KB Ok
5 Correct 72 ms 16116 KB Ok
6 Correct 40 ms 8176 KB Ok
7 Correct 34 ms 8152 KB Ok
8 Correct 17 ms 4444 KB Ok
9 Correct 18 ms 4440 KB Ok
10 Correct 9 ms 2392 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 1 ms 456 KB Ok
13 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 152 ms 32084 KB Ok
2 Correct 73 ms 16080 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 4 ms 1232 KB Ok
8 Correct 78 ms 16080 KB Ok
9 Correct 35 ms 8280 KB Ok
10 Correct 1 ms 344 KB Ok
11 Correct 1 ms 604 KB Ok
12 Correct 17 ms 4276 KB Ok
13 Correct 1 ms 348 KB Ok
14 Correct 157 ms 32356 KB Ok
15 Correct 157 ms 32092 KB Ok
16 Correct 151 ms 32204 KB Ok
17 Correct 75 ms 16328 KB Ok
18 Correct 72 ms 16116 KB Ok
19 Correct 40 ms 8176 KB Ok
20 Correct 34 ms 8152 KB Ok
21 Correct 17 ms 4444 KB Ok
22 Correct 18 ms 4440 KB Ok
23 Correct 9 ms 2392 KB Ok
24 Correct 1 ms 348 KB Ok
25 Correct 1 ms 456 KB Ok
26 Correct 0 ms 348 KB Ok
27 Correct 160 ms 32068 KB Ok
28 Correct 97 ms 16292 KB Ok
29 Correct 159 ms 32380 KB Ok
30 Correct 8 ms 2392 KB Ok
31 Correct 1 ms 344 KB Ok
32 Correct 4 ms 1372 KB Ok
33 Correct 17 ms 4444 KB Ok
34 Correct 0 ms 348 KB Ok
35 Correct 0 ms 348 KB Ok
36 Correct 1 ms 348 KB Ok
37 Correct 0 ms 412 KB Ok
38 Correct 76 ms 16084 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 77 ms 16084 KB Ok
2 Correct 173 ms 32204 KB Ok
3 Correct 166 ms 32332 KB Ok
4 Correct 11 ms 2392 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 18 ms 4220 KB Ok
7 Correct 154 ms 32184 KB Ok
8 Correct 1 ms 344 KB Ok
9 Correct 1 ms 460 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 43 ms 8152 KB Ok
12 Correct 85 ms 16144 KB Ok