답안 #1022318

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

const int N = 20;
int n, c;
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 << c), v);
        c++;
    }
}

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;
        c = 0;
        dfs(0, r);
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Duplicate edges
2 Halted 0 ms 0 KB -