結果

問題 No.1061 素敵な数列
ユーザー milanis48663220milanis48663220
提出日時 2020-05-22 23:35:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,236 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 19:08:05
合計ジャッジ時間 5,765 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 11 ms
5,376 KB
testcase_22 AC 19 ms
5,512 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 15 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 11 ms
5,376 KB
testcase_29 AC 15 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 10 ms
5,376 KB
testcase_32 AC 22 ms
5,472 KB
testcase_33 WA -
testcase_34 AC 6 ms
5,376 KB
testcase_35 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    if(N == 1){
        cout << "0 0 0" << endl;
        return 0;
    }
    if(N == 2){
        cout << -1 << endl;
        return 0;
    }
    N--;
    int M = (N+1)/3;
    int k = M, l = M, m = M;
    if((N+1)%3 == 1){
        k++;
    }else if((N+1)%3 == 2){
        k++; l++;
    }
    vector<int> ans;
    for(int i = k-1; i >= 0; i--) {
        ans.push_back(i*3); ans.push_back(i*3);
    }
    for(int i = 0; i <= k-1; i++) {
        ans.push_back(i*3);
    }

    for(int i = l-1; i >= 0; i--) {
        ans.push_back(i*3+1);
    }
    ans.push_back(m*3-1); 
    for(int i = 0; i <= l-1; i++) {
        ans.push_back(i*3+1); ans.push_back(i*3+1);
    }

    for(int i = m-2; i >= 0; i--) {
        ans.push_back(i*3+2); 
    }
    ans.push_back(m*3-1); ans.push_back(m*3-1);
    for(int i = 0; i <= m-2; i++) {
        ans.push_back(i*3+2); ans.push_back(i*3+2);
    }
   
    for(auto i : ans) cout << i << ' ';
    cout << endl;
}
0