# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1059485 | 2024-08-15T03:24:14 Z | Thanhs | Hiperkocka (COCI21_hiperkocka) | C++14 | 29 ms | 3724 KB |
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) #define fi first #define se second #define all(x) x.begin(), x.end() // mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); // int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);} const int NM = 16 + 5; const int LM = 1e4 + 5; const int mod = 1e9 + 7; vector<pair<int, int>> g[NM]; vector<int> v; int n; void dfs(int u, int p = -1, int m = 0) { v[u] = m; for (pair<int, int> v : g[u]) if (v.fi != p) dfs(v.fi, u, m | (1 << v.se)); } void solve() { cin >> n; for (int i = 0; i < n; i++) { int u, v; cin >> u >> v; g[u].push_back({v, i}); g[v].push_back({u, i}); } v.resize(n + 1); dfs(0); cout << (1 << n - 1) << endl; for (int i = 0; i < (1 << n); i++) if (__builtin_popcount(i) & 1 ^ 1) { for (int t : v) cout << (t ^ i) << ' '; cout << endl; } } signed main() { fastIO if (fopen("in.txt", "r")) { freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); } int tc = 1; // cin >> tc; while (tc--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 452 KB | Output is correct |
8 | Correct | 0 ms | 412 KB | Output is correct |
9 | Correct | 27 ms | 3516 KB | Output is correct |
10 | Correct | 4 ms | 604 KB | Output is correct |
11 | Correct | 6 ms | 1116 KB | Output is correct |
12 | Correct | 27 ms | 3676 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 29 ms | 3676 KB | Output is correct |
15 | Correct | 13 ms | 1884 KB | Output is correct |
16 | Correct | 6 ms | 1116 KB | Output is correct |
17 | Correct | 27 ms | 3668 KB | Output is correct |
18 | Correct | 28 ms | 3668 KB | Output is correct |
19 | Correct | 27 ms | 3676 KB | Output is correct |
20 | Correct | 26 ms | 3708 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 28 ms | 3488 KB | Output is correct |
23 | Correct | 28 ms | 3724 KB | Output is correct |
24 | Correct | 27 ms | 3676 KB | Output is correct |
25 | Correct | 28 ms | 3724 KB | Output is correct |
26 | Correct | 13 ms | 1884 KB | Output is correct |