#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=17;
int const mod=1e9+7;
vector<int> adj[N];
int path[N];
int c=0;
void dfs(int node,int par=-1){
for(int i:adj[node]){
if(i==par)
continue;
path[i]=path[node]^(1<<c);
c++;
dfs(i,node);
}
}
int main(){
int n;
cin>>n;
for (int i = 0; i < n; ++i)
{
int u,v;
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
dfs(0);
cout<<(1<<(n-1))<<endl;
for (int b = 0; b < (1<<n); ++b)
{
if(__builtin_popcount(b) & 1)
continue;
for (int i = 0; i <=n; ++i)
cout<<((path[i])^(b))<<' ';
cout<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
93 ms |
3668 KB |
Output is correct |
10 |
Correct |
9 ms |
604 KB |
Output is correct |
11 |
Correct |
16 ms |
860 KB |
Output is correct |
12 |
Correct |
66 ms |
3708 KB |
Output is correct |
13 |
Correct |
2 ms |
344 KB |
Output is correct |
14 |
Correct |
68 ms |
3668 KB |
Output is correct |
15 |
Correct |
32 ms |
1800 KB |
Output is correct |
16 |
Correct |
16 ms |
856 KB |
Output is correct |
17 |
Correct |
82 ms |
3664 KB |
Output is correct |
18 |
Correct |
67 ms |
3664 KB |
Output is correct |
19 |
Correct |
68 ms |
3668 KB |
Output is correct |
20 |
Correct |
77 ms |
3664 KB |
Output is correct |
21 |
Correct |
2 ms |
344 KB |
Output is correct |
22 |
Correct |
65 ms |
3668 KB |
Output is correct |
23 |
Correct |
67 ms |
3472 KB |
Output is correct |
24 |
Correct |
69 ms |
3608 KB |
Output is correct |
25 |
Correct |
68 ms |
3500 KB |
Output is correct |
26 |
Correct |
34 ms |
1676 KB |
Output is correct |