結果
問題 | No.2719 Equal Inner Products in Permutation |
ユーザー | Shreyan Ray |
提出日時 | 2024-04-05 23:11:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 2,125 bytes |
コンパイル時間 | 2,310 ms |
コンパイル使用メモリ | 208,756 KB |
実行使用メモリ | 17,676 KB |
最終ジャッジ日時 | 2024-10-01 03:03:29 |
合計ジャッジ時間 | 7,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,816 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 2 ms
6,820 KB |
testcase_08 | AC | 2 ms
6,816 KB |
testcase_09 | AC | 2 ms
6,816 KB |
testcase_10 | AC | 3 ms
6,820 KB |
testcase_11 | AC | 2 ms
6,820 KB |
testcase_12 | AC | 3 ms
6,816 KB |
testcase_13 | AC | 3 ms
6,820 KB |
testcase_14 | AC | 3 ms
6,816 KB |
testcase_15 | AC | 55 ms
15,264 KB |
testcase_16 | AC | 61 ms
16,940 KB |
testcase_17 | AC | 38 ms
11,760 KB |
testcase_18 | AC | 61 ms
17,280 KB |
testcase_19 | AC | 51 ms
14,824 KB |
testcase_20 | AC | 35 ms
11,132 KB |
testcase_21 | AC | 61 ms
17,484 KB |
testcase_22 | AC | 46 ms
13,848 KB |
testcase_23 | AC | 40 ms
12,536 KB |
testcase_24 | AC | 34 ms
10,712 KB |
testcase_25 | AC | 62 ms
17,544 KB |
testcase_26 | AC | 63 ms
17,548 KB |
testcase_27 | AC | 63 ms
17,544 KB |
testcase_28 | AC | 63 ms
17,676 KB |
testcase_29 | AC | 63 ms
17,672 KB |
testcase_30 | AC | 62 ms
17,672 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define INF (int)1e18 #define f first #define s second mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); vector <int> s1, s2, s3; void work2(vector <int> a){ int n = a.size(); int m = n / 3; for (int i = 0; i < m; i++){ s1.push_back(a[i]); s2.push_back(a[i + m]); s3.push_back(a[i + 2 * m]); } } void work(int n){ if (n == 2){ work2({1, 4, 3, 6, 5, 2}); } else if (n == 3){ work2({1, 2, 8, 3, 6, 9, 7, 5, 4}); } else if (n == 4){ work2({1, 2, 4, 11, 7, 9, 10, 12, 8, 5, 6, 3}); } else if (n == 5) { work2({1, 2, 3, 8, 13, 7, 10, 12, 14, 15, 11, 9, 6, 4, 5}); } else { work(n - 4); int m = 3 * n - 12; work2({m + 5, m + 8, m + 10, m + 11, m + 1, m + 2, m + 3, m + 4, m + 6, m + 7, m + 9, m + 12}); } } void Solve() { int n; cin >> n; if (n == 1){ cout << -1 << "\n"; return; } work(n); int v1 = 0, v2 = 0; vector <bool> ok(3 * n + 1, false); for (int i = 0; i < n; i++){ v1 += s1[i] * s2[i]; v2 += s2[i] * s3[i]; ok[s1[i]] = true; ok[s2[i]] = true; ok[s3[i]] = true; } for (auto x : s1) cout << x << " "; for (auto x : s2) cout << x << " "; for (auto x : s3) cout << x << " "; if (v1 != v2){ cout << "NOOO\n"; } for (int i = 1; i <= 3 * n; i++) if (!ok[i]){ cout << "NOOB\n"; } } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // freopen("in", "r", stdin); // freopen("out", "w", stdout); // 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; }