#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#define F first
#define S second
#define PB push_back
#define M ll(998244353)
#define sz(x) (ll)x.size()
#define N 1000005
#define pri(x) cout << x << endl
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ << " " <<
using namespace std;
//typedef tree <ll, null_type, less_equal <ll> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
vector <pair <int, int> > g[N];
vector <int> cube;
void dfs(int v, int x, int p)
{
cube.PB(x);
for (auto it : g[v])
{
if (it.F == p)
continue;
dfs(it.F, x ^ (1 << it.S), v);
}
}
int main()
{
istream::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// freopen("1.in", "r", stdin);
// freopen("trains.in", "r", stdin);
// freopen("trains.out", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int x, y;
cin >> x >> y;
g[x].PB({y, i});
g[y].PB({x, i});
}
dfs(0, 0, -1);
vector <vector <int> > ans; ans.clear();
for (int i = 0; i < (1 << n); i++)
if (__builtin_popcount(i) % 2 == 0)
{
ans.emplace_back();
for (auto it : cube)
ans.back().PB(it ^ i);
}
pri(sz(ans));
for (auto it : ans)
{
for (auto itr : it)
cout << itr << " ";
cout << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23756 KB |
Output is correct |
2 |
Incorrect |
13 ms |
23800 KB |
Edge is not in hipercube |
3 |
Halted |
0 ms |
0 KB |
- |