Submission #529636

#TimeUsernameProblemLanguageResultExecution timeMemory
529636topovikHiperkocka (COCI21_hiperkocka)C++14
4.81 / 110
19 ms12620 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define s second using namespace std; typedef long long ll; typedef long double ld; const ll oo = 1e18 + 7; const ll N = 5e5 + 10; const ll M = 1000; const ll M1 = 1e6; int n; bool mrk[N]; vector <int> a[N]; vector <int> ans; vector <vector <int> > ans1; bool check(int x) { for (int i = 0; i < n; i++) if (x == (1 << i)) return 1; return 0; } void Rec(int x, int y, int prv) { // cout << x << " " << y << " " << prv << endl; ans[y] = x; mrk[x] = 1; for (auto i : a[y]) if (i != prv) { for (int j = 1; ; j <<= 1) if (!mrk[j ^ x]) { mrk[j ^ x] = 1; Rec(j ^ x, i, y); break; } } } int main() { ios_base::sync_with_stdio(0); iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0); srand(time(NULL)); cin >> n; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; a[x].pb(y); a[y].pb(x); } ans.resize(n + 1); Rec(0, 0, 0); // cout << "Yes\n"; ans1.pb(ans); for (int x = 0; x < (1 << n); x++) { bool g = 1; for (int i = 0; i <= n; i++) g &= !mrk[ans[i] ^ x]; if (g) { ans1.pb(ans); for (int i = 0; i <= n; i++) ans1.back()[i] ^= x; for (int i = 0; i <= n; i++) mrk[ans1.back()[i]] = 1; } } cout << ans1.size() << endl; for (auto i : ans1) { for (auto j : i) cout << j << " "; cout << endl; } } /* 5 3 2 1 1 2 2 3 2 3 3 4 4 5 4 1 1 2 2 3 3 4 4 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...