# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548123 | aryan12 | Hiperkocka (COCI21_hiperkocka) | C++17 | 53 ms | 3660 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.
#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
int n;
const int N = 17;
vector<pair<int, int> > g[N];
int val[N];
int power(int a, int b)
{
if(b == 0)
{
return 1;
}
if(b == 1)
{
return a;
}
int x = power(a, b / 2);
x *= x;
if(b & 1)
{
x *= a;
}
return x;
}
void dfs(int node, int par)
{
for(auto [to, wt]: g[node])
{
if(to == par) continue;
val[to] = val[node] ^ wt;
dfs(to, node);
}
}
void Solve()
{
cin >> n;
for(int i = 0; i < n; i++)
{
int u, v;
cin >> u >> v;
g[u].push_back(make_pair(v, power(2, i)));
g[v].push_back(make_pair(u, power(2, i)));
}
val[0] = 0;
dfs(0, -1);
cout << power(2, n - 1) << "\n";
for(int i = 0; i <= n; i++)
{
cout << val[i] << " ";
}
cout << "\n";
for(int i = 1; i < (1 << n); i++)
{
if(__builtin_popcount(i) % 2 == 0)
{
for(int j = 0; j <= n; j++)
{
cout << (val[j] ^ i) << " ";
}
cout << "\n";
}
}
}
int32_t main()
{
auto begin = std::chrono::high_resolution_clock::now();
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
for(int i = 1; i <= t; i++)
{
//cout << "Case #" << i << ": ";
Solve();
}
auto end = std::chrono::high_resolution_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |