結果
問題 |
No.2719 Equal Inner Products in Permutation
|
ユーザー |
![]() |
提出日時 | 2024-04-05 23:28:19 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,574 bytes |
コンパイル時間 | 2,248 ms |
コンパイル使用メモリ | 196,004 KB |
最終ジャッジ日時 | 2025-02-20 22:05:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 WA * 5 |
ソースコード
#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 % 4 == 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) { 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 == 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; }