Submission #548123

#TimeUsernameProblemLanguageResultExecution timeMemory
548123aryan12Hiperkocka (COCI21_hiperkocka)C++17
110 / 110
53 ms3660 KiB
#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 timeMemoryGrader output
Fetching results...