# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
744632 | MohamedAhmed04 | Hiperkocka (COCI21_hiperkocka) | C++14 | 47 ms | 3600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |