Submission #706724

# Submission time Handle Problem Language Result Execution time Memory
706724 2023-03-07T14:56:00 Z Username4132 Hiperkocka (COCI21_hiperkocka) C++14
0 / 110
0 ms 212 KB
#include<iostream>
#include<vector>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define PB push_back

const int MAXN = 18;
int n, cnt;
vector<int> g[MAXN];

void dfs(int v, int p, int cur){
    ++cnt;
    printf("%d ", cur);
    for(int to:g[v]){
        if(to==p) continue;
        dfs(to, v, cur^(1<<cnt));
    }
}

int main(){
    scanf("%d", &n);
    forn(i, n){
        int a, b; scanf("%d %d", &a, &b);
        g[a].PB(b), g[b].PB(a);
    }
    printf("%d\n", 1<<(n-1));
    forn(i, 1<<n) if(!(i && (__builtin_popcount(i)&1))) cnt=-1, dfs(0, 0, i), printf("\n");
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:23:24: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         int a, b; scanf("%d %d", &a, &b);
      |                   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Edge is not in hipercube
3 Halted 0 ms 0 KB -