#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+2;
const int mod = 1e9 + 7;
int n;
vector<pair<int, int>>G[20];
int ans[20];
void dfs (int nod, int val, int par) {
ans[nod] = val;
for (auto it : G[nod]) {
if (it.first == par) continue;
dfs(it.first, val ^ (1 << it.second), nod);
}
}
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
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, 0, 0);
cout << (1 << (n - 1)) << "\n";
for (int i = 0; i < (1 << n); i++)
if (__builtin_popcount(i) % 2 == 0) {
for (int j = 0; j <= n; j++)
cout << (i ^ ans[j]) << " ";
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
368 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
452 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
45 ms |
3520 KB |
Output is correct |
10 |
Correct |
5 ms |
604 KB |
Output is correct |
11 |
Correct |
7 ms |
1116 KB |
Output is correct |
12 |
Correct |
34 ms |
3716 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
35 ms |
3540 KB |
Output is correct |
15 |
Correct |
15 ms |
1884 KB |
Output is correct |
16 |
Correct |
7 ms |
1116 KB |
Output is correct |
17 |
Correct |
33 ms |
3668 KB |
Output is correct |
18 |
Correct |
34 ms |
3556 KB |
Output is correct |
19 |
Correct |
31 ms |
3668 KB |
Output is correct |
20 |
Correct |
32 ms |
3712 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
32 ms |
3624 KB |
Output is correct |
23 |
Correct |
38 ms |
3696 KB |
Output is correct |
24 |
Correct |
40 ms |
3680 KB |
Output is correct |
25 |
Correct |
32 ms |
3564 KB |
Output is correct |
26 |
Correct |
21 ms |
2128 KB |
Output is correct |