#include <bits/stdc++.h>
using namespace std;
const int N = 17;
int n;
vector<int> g[N];
vector<pair<int, int>> edges;
void dfs(int v, int r, int p = -1){
cout << r << " ";
for (int e : g[v]){
int u = edges[e].first + edges[e].second - v;
if (u == p) continue;
dfs(u, r ^ (1 << e), v);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i ++){
int u, v;
cin >> u >> v;
g[u].push_back(i);
g[v].push_back(i);
edges.push_back({u, v});
}
cout << (1 << (n - 1)) << endl;
for (int r = 0; r < (1 << n); r ++){
if (__builtin_popcount(r) % 2) continue;
dfs(0, r);
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Edge is not in hipercube |
3 |
Halted |
0 ms |
0 KB |
- |