Submission #744632

#TimeUsernameProblemLanguageResultExecution timeMemory
744632MohamedAhmed04Hiperkocka (COCI21_hiperkocka)C++14
110 / 110
47 ms3600 KiB
#include <bits/stdc++.h> using namespace std ; const int MAX = 17 ; int arr[MAX] ; int n ; vector< vector<int> >adj(MAX) ; int val[MAX] ; int cnt = 0 ; void dfs(int node , int par) { for(auto &child : adj[node]) { if(child == par) continue ; val[child] = val[node] ^ (1 << cnt) ; ++cnt ; dfs(child , node) ; } } int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n ; for(int i = 0 ; i < n ; ++i) { int x , y ; cin>>x>>y ; adj[x].push_back(y) ; adj[y].push_back(x) ; } dfs(0 , -1) ; cout<<(1 << (n-1))<<"\n" ; for(int mask = 0 ; mask < (1 << n) ; ++mask) { if((__builtin_popcount(mask) & 1)) continue ; for(int i = 0 ; i <= n ; ++i) cout<<(val[i] ^ mask)<<" " ; cout<<"\n" ; } return 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...