# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1059485 | Thanhs | Hiperkocka (COCI21_hiperkocka) | C++14 | 29 ms | 3724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define all(x) x.begin(), x.end()
// mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
// int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
const int NM = 16 + 5;
const int LM = 1e4 + 5;
const int mod = 1e9 + 7;
vector<pair<int, int>> g[NM];
vector<int> v;
int n;
void dfs(int u, int p = -1, int m = 0)
{
v[u] = m;
for (pair<int, int> v : g[u])
if (v.fi != p)
dfs(v.fi, u, m | (1 << v.se));
}
void solve()
{
cin >> n;
for (int i = 0; i < n; i++)
{
int u, v;
cin >> u >> v;
g[u].push_back({v, i});
g[v].push_back({u, i});
}
v.resize(n + 1);
dfs(0);
cout << (1 << n - 1) << endl;
for (int i = 0; i < (1 << n); i++)
if (__builtin_popcount(i) & 1 ^ 1)
{
for (int t : v)
cout << (t ^ i) << ' ';
cout << endl;
}
}
signed main()
{
fastIO
if (fopen("in.txt", "r"))
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
int tc = 1;
// cin >> tc;
while (tc--)
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |