#include<bits/stdc++.h>
using namespace std;
const int N = 20;
vector<int> G[N];
int path[N];
int cnt = 0;
void dfs(int v, int p = 0)
{
// cerr << v << ' ' << path[v] << endl;
for(int u : G[v])
if(u != p)
{
path[u] = path[v] ^ (1 << cnt);
cnt++;
dfs(u, v);
}
}
int main()
{
int n;
cin >> n;
for(int i = 0; i < n; i ++)
{
int u, v;
cin >> u >> v;
G[u].push_back(v);
G[v].push_back(u);
}
dfs(0);
cout << (1 << (n - 1)) << endl;
for(int mask = 0; mask < (1 << n); mask ++)
{
if(__builtin_popcount(mask) % 2) continue;
for(int i = 0; i <= n; i ++)
cout << (path[i] ^ mask) << ' ';
cout << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
69 ms |
3604 KB |
Output is correct |
10 |
Correct |
7 ms |
724 KB |
Output is correct |
11 |
Correct |
16 ms |
860 KB |
Output is correct |
12 |
Correct |
66 ms |
3664 KB |
Output is correct |
13 |
Correct |
4 ms |
628 KB |
Output is correct |
14 |
Correct |
64 ms |
3568 KB |
Output is correct |
15 |
Correct |
32 ms |
1872 KB |
Output is correct |
16 |
Correct |
22 ms |
860 KB |
Output is correct |
17 |
Correct |
66 ms |
3620 KB |
Output is correct |
18 |
Correct |
66 ms |
3668 KB |
Output is correct |
19 |
Correct |
76 ms |
3684 KB |
Output is correct |
20 |
Correct |
66 ms |
3592 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
65 ms |
3608 KB |
Output is correct |
23 |
Correct |
67 ms |
3512 KB |
Output is correct |
24 |
Correct |
67 ms |
3680 KB |
Output is correct |
25 |
Correct |
66 ms |
3668 KB |
Output is correct |
26 |
Correct |
31 ms |
1872 KB |
Output is correct |