// UUID: 9ee69411-7c05-495a-9d4e-b4b7bf9490b1
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int> > > g;
vector<int> val;
void dfs(int v, int p)
{
for(auto [x, ind] : g[v])
{
if(x != p)
{
val[x] = val[v] ^ (1 << ind);
dfs(x, v);
}
}
}
int main() {
int n;
cin >> n;
g.resize(n + 1);
val.resize(n + 1);
for(int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
g[x].push_back({y, i});
g[y].push_back({x, i});
}
dfs(0, -1);
const int e = (1 << n);
cout << e / 2 << "\n";
for(int i = 0; i < e; i++)
{
if(__builtin_popcount(i) % 2 == 1) continue;
for(int j = 0; j <= n; j++)
{
cout << (i ^ val[j]) << " ";
}
cout << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |