제출 #1271198

#제출 시각아이디문제언어결과실행 시간메모리
1271198algoproclubHiperkocka (COCI21_hiperkocka)C++20
110 / 110
31 ms3708 KiB
// UUID: 1112528c-9c29-4d72-83a3-1bc3fa9d3cec #include <iostream> #include <vector> using namespace std; vector<vector<int>> t; vector<int> ans; void get_ans(int tnode, int tparent, int cubenode) { ans[tnode] = cubenode; for (int tneighbour : t[tnode]) { if (tneighbour == tparent) continue; get_ans(tneighbour, tnode, cubenode ^ (1 << tneighbour)); } } int main() { int n; cin >> n; t.resize(n + 1); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; t[x].push_back(y); t[y].push_back(x); } cout << (1 << (n - 1)) << '\n'; ans.resize(n + 1); for (int start = 0; start < (1 << n); start++) { if (__builtin_popcount(start) & 1) continue; get_ans(n, -1, start); for (int i = 0; i <= n; i++) cout << ans[i] << ' '; cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...