結果

問題 No.2719 Equal Inner Products in Permutation
ユーザー otoshigootoshigo
提出日時 2024-04-06 02:57:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,617 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 208,440 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-06 02:58:00
合計ジャッジ時間 7,597 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 41 ms
6,676 KB
testcase_16 AC 46 ms
6,676 KB
testcase_17 AC 30 ms
6,676 KB
testcase_18 AC 47 ms
6,676 KB
testcase_19 AC 39 ms
6,676 KB
testcase_20 AC 27 ms
6,676 KB
testcase_21 AC 47 ms
6,676 KB
testcase_22 AC 35 ms
6,676 KB
testcase_23 AC 32 ms
6,676 KB
testcase_24 AC 26 ms
6,676 KB
testcase_25 AC 49 ms
6,676 KB
testcase_26 AC 48 ms
6,676 KB
testcase_27 AC 48 ms
6,676 KB
testcase_28 AC 48 ms
6,676 KB
testcase_29 AC 49 ms
6,676 KB
testcase_30 AC 49 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin>>N;
    if(N==1){
        cout<<-1<<"\n";
    }else if(N==2){
        cout<<"1 4 3 6 5 2\n";
    }else if(N==5){
        cout<<"1 2 3 9 15 10 12 13 14 11 4 5 6 7 8\n";
    }else{
        vector<vector<int>>v3={{1,2,9},{6,8,7},{3,4,5}};
        vector<vector<int>>v4={{1,2,5,12},{8,10,11,9},{3,6,4,7}};
        vector<vector<int>>ans(3);
        int s=0;
        for(int i=0;i<4;i++){
            if((N-3*i)%4==0){
                for(int j=0;j<i;j++){
                    for(int k=0;k<3;k++){
                        for(auto x:v3[k]){
                            ans[k].push_back(x+s);
                        }
                    }
                    s+=9;
                }
                for(int j=0;j<(N-3*i)/4;j++){
                    for(int k=0;k<3;k++){
                        for(auto x:v4[k]){
                            ans[k].push_back(x+s);
                        }
                    }
                    s+=12;
                }
            }
        }
        for(int i=0;i<3;i++){
            for(int j=0;j<N;j++){
                cout<<ans[i][j]<<" ";
            }
        }
        cout<<"\n";
    }
}
0