답안 #1022310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022310 2024-07-13T11:59:20 Z vjudge1 Hiperkocka (COCI21_hiperkocka) C++17
0 / 110
1 ms 356 KB
#include <bits/stdc++.h>
using namespace std;

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

void dfs(int v, int r, int p = -1){
    cout << r << " ";
    for (int e : g[v]){
        int u = edges[e].first + edges[e].second - v;
        if (u == p) continue;
        dfs(u, r ^ (1 << e), 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});
    }

    cout << (1 << (n - 1)) << endl;
    for (int r = 0; r < (1 << n); r ++){
        if (__builtin_popcount(r) % 2) continue;
        dfs(0, r);
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 356 KB Edge is not in hipercube
3 Halted 0 ms 0 KB -