// UUID: 790519c5-0e0d-4ca4-9794-cb10207dd4a0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll>edges[17];
ll h[17];
void dfs(ll x, ll p)
{
if(x!=0) h[x]=(h[p]^(1<<(x-1)));
for(auto next:edges[x])
{
if(next!=p) dfs(next, x);
}
}
int main() {
ll n; cin>>n;
for(ll i=0; i<n; i++)
{
ll a,b;
cin>>a>>b;
edges[a].push_back(b);
edges[b].push_back(a);
}
dfs(0,0);
cout<<(1<<(n-1))<<endl;
for(ll i=0; i<(1<<n); i++)
{
if((__builtin_popcount(i)%2)==0)
{
for(ll j=0; j<=n; j++)
{
cout<<(h[j]^i)<<" ";
}cout<<"\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |