Submission #1022335

# Submission time Handle Problem Language Result Execution time Memory
1022335 2024-07-13T12:06:48 Z vjudge1 Hiperkocka (COCI21_hiperkocka) C++17
110 / 110
639 ms 3672 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 20;
int n, path[N];
vector<int> g[N];
vector<pair<int, int>> edges;

void dfs(int v, int p = -1){
    for (int e : g[v]){
        int u = edges[e].first + edges[e].second - v;
        if (u == p) continue;
        path[u] = path[v] ^ (1 << e);
        dfs(u, v);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; i ++){
        int u, v;
        cin >> u >> v;

        g[u].push_back(i);
        g[v].push_back(i);
        edges.push_back({u, v});
    }

    dfs(0);
    cout << (1 << (n - 1)) << endl;
    for (int r = 0; r < (1 << n); r ++){
        if (__builtin_popcount(r) % 2) continue;
        for (int i = 0; i <= n; i ++)
            cout << (path[i] ^ r) << endl;
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 5 ms 460 KB Output is correct
8 Correct 7 ms 600 KB Output is correct
9 Correct 639 ms 3672 KB Output is correct
10 Correct 57 ms 544 KB Output is correct
11 Correct 143 ms 1056 KB Output is correct
12 Correct 571 ms 3660 KB Output is correct
13 Correct 13 ms 348 KB Output is correct
14 Correct 576 ms 3528 KB Output is correct
15 Correct 301 ms 1800 KB Output is correct
16 Correct 138 ms 1132 KB Output is correct
17 Correct 570 ms 3660 KB Output is correct
18 Correct 609 ms 3552 KB Output is correct
19 Correct 565 ms 3668 KB Output is correct
20 Correct 566 ms 3664 KB Output is correct
21 Correct 6 ms 348 KB Output is correct
22 Correct 552 ms 3664 KB Output is correct
23 Correct 550 ms 3616 KB Output is correct
24 Correct 581 ms 3668 KB Output is correct
25 Correct 549 ms 3672 KB Output is correct
26 Correct 278 ms 1812 KB Output is correct