結果
問題 |
No.2719 Equal Inner Products in Permutation
|
ユーザー |
![]() |
提出日時 | 2024-04-05 23:31:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 1,916 bytes |
コンパイル時間 | 2,060 ms |
コンパイル使用メモリ | 196,012 KB |
最終ジャッジ日時 | 2025-02-20 22:06:01 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define all(v) (v).begin(),(v).end() #define pb(a) push_back(a) #define rep(i, n) for(int i=0;i<n;i++) #define foa(e, v) for(auto&& e : v) using ll = long long; const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60); #define dout(a) cout<<fixed<<setprecision(10)<<a<<endl; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; if(n == 1) { cout << -1 << endl; return 0; } vector<int> ans(n * 3, -1); rep(i, n) ans[i + n] = (i + 1) * 3; int m = n; while(m) { if(m == 4 or m >= 6) { int num = m * 3; ans[m - 1] = num - 1; ans[m - 1 + n * 2] = num - 2; num -= 3; m --; ans[m - 1] = num - 2; ans[m - 1 + n * 2] = num - 1; num -= 3; m --; ans[m - 1] = num - 2; ans[m - 1 + n * 2] = num - 1; num -= 3; m --; ans[m - 1] = num - 1; ans[m - 1 + n * 2] = num - 2; num -= 3; m --; continue; } if(m == 5) { m -= 5; ans[0] = 11; ans[1] = 1; ans[2] = 4; ans[3] = 7; ans[4] = 14; ans[n * 2] = 10; ans[n * 2 + 1] = 5; ans[n * 2 + 2] = 2; ans[n * 2 + 3] = 8; ans[n * 2 + 4] = 13; } else if(m == 3) { ans[0] = 1; ans[1] = 2; ans[2] = 8; ans[n * 2] = 7; ans[n * 2 + 1] = 5; ans[n * 2 + 2] = 4; m -= 3; } else { ans[0] = 1; ans[1] = 4; ans[n * 2] = 5; ans[n * 2 + 1] = 2; m -= 2; } } foa(e, ans) cout << e << " "; cout << endl; return 0; }