結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー shinchanshinchan
提出日時 2024-04-05 23:31:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,916 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 203,448 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 23:31:35
合計ジャッジ時間 7,490 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 40 ms
6,676 KB
testcase_16 AC 45 ms
6,676 KB
testcase_17 AC 29 ms
6,676 KB
testcase_18 AC 45 ms
6,676 KB
testcase_19 AC 37 ms
6,676 KB
testcase_20 AC 26 ms
6,676 KB
testcase_21 AC 45 ms
6,676 KB
testcase_22 AC 34 ms
6,676 KB
testcase_23 AC 31 ms
6,676 KB
testcase_24 AC 26 ms
6,676 KB
testcase_25 AC 47 ms
6,676 KB
testcase_26 AC 48 ms
6,676 KB
testcase_27 AC 47 ms
6,676 KB
testcase_28 AC 48 ms
6,676 KB
testcase_29 AC 48 ms
6,676 KB
testcase_30 AC 47 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0