Submission #1313945

#TimeUsernameProblemLanguageResultExecution timeMemory
1313945raspyHiperkocka (COCI21_hiperkocka)C++20
110 / 110
29 ms3684 KiB
#include <bits/stdc++.h> #define int long long #define vi vector<int> #define ii pair<int, int> #define f first #define s second #define all(x) (x).begin(), (x).end() #define P 31 #define mod 1'000'000'007 #define inf 1'000'000'000'000'000'000 #define pb push_back #define str string #define sz(x) (x).size() #define vvi vector<vi> #define fun function #define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define file freopen("problemname.in", "r", stdin); freopen("pr.out", "w", stdout); #define dbg(v) cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; template <class T, int SZ> using arr = array<T, SZ>; vi graf[30]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { int u, v; cin >> u >> v; graf[u].pb(v); graf[v].pb(u); } cout << (1ll<<n-1) << "\n"; for (int i = 0; i < (1ll<<n); i++) { if (__builtin_popcountll(i)%2) continue; vi id(n+1, -1); id[0]=i; queue<int> q; q.push(0); int st=0; while (!q.empty()) { int u = q.front(); q.pop(); for (int v:graf[u]) { if (id[v]==-1) { // cout << v << " " << id[u] << "\n"; id[v]=(id[u]^(1ll<<st)); st++; q.push(v); } } } for (int v:id) cout << v << " "; cout << "\n"; } } signed main() { oopt; int t = 1; // cin >> t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...