#include <bits/stdc++.h>
using namespace std;
//~ #define int long long
#define fr first
#define sc second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(),x.end()
#define sp << " " <<
#define inf 1e18+1
#define N 200000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tuple<int,int,int> tiii;
typedef pair<int,int> pii;
int say=0;
vector<int> v[17],d(17);
void dfs(int x,int ata){
for(auto i:v[x]){
if(i==ata) continue;
d[i]=d[x]^(1<<say);
say++;
dfs(i,x);
}
}
void solve(){
int n;
cin >> n;
for(int i=0;i<n;i++){
int x,y;
cin >> x >> y;
v[x].pb(y);
v[y].pb(x);
}
dfs(0,0);
cout << (1<<(n-1)) << endl;
for(int i=0;i<(1<<n);i++){
if(__builtin_popcount(i)&1) continue;
for(int j=0;j<=n;j++){
cout << (i^d[j]) << " ";
}
cout << endl;
}
}
int32_t main(){
fast;
int test=1;
//~ cin >> test;
while(test--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |