結果

問題 No.1061 素敵な数列
ユーザー kyort0nkyort0n
提出日時 2020-05-22 21:56:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,596 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 168,832 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2024-04-15 16:43:08
合計ジャッジ時間 5,755 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
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 AC 8 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 13 ms
5,376 KB
testcase_22 AC 24 ms
5,632 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 19 ms
5,376 KB
testcase_25 AC 18 ms
5,376 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 13 ms
5,376 KB
testcase_29 AC 17 ms
5,376 KB
testcase_30 AC 21 ms
5,504 KB
testcase_31 AC 12 ms
5,376 KB
testcase_32 AC 25 ms
5,888 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 7 ms
5,376 KB
testcase_35 AC 8 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    if(N == 1) {
        cout << "0 0 0" << endl;
        return 0;
    }
    if(N == 2) {
        cout << -1 << endl;
        return 0;
    }
    deque<ll> zero, one, two;
    ll c = N - 1;
    N--;
    N--;
    ll onenum = (N + 2) / 3;
    ll twonum = (N + 1) / 3;
    for(ll i = 0; i <= N; i += 3) {
        zero.push_front(i);
        zero.push_front(i);
        zero.push_back(i);
    }
    one.push_back(c);
    ll rest = c - onenum - twonum;
    for(ll i = 1; i <= N; i += 3) {
        one.push_back(i);
        one.push_front(i);
        if(rest) {
            one.push_back(i);
            rest--;
        } else {
            one.push_front(i);
        }
    }
    two.push_back(c);
    two.push_back(c);
    for(ll i = 2; i <= N; i += 3) {
        two.push_back(i);
        two.push_front(i);
        if(rest) {
            two.push_front(i);
            rest--;
        } else {
            two.push_back(i);
        }
    }
    for(auto c : zero) cout << c << " ";
    for(auto c : one) cout << c << " ";
    for(auto c : two) cout << c << " ";
    return 0;
}
0