結果

問題 No.360 増加門松列
ユーザー xuzijian629xuzijian629
提出日時 2018-10-31 16:30:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 2,478 ms
コンパイル使用メモリ 204,116 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-12 11:38:11
合計ジャッジ時間 3,365 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

bool is_kadomatsu(vi as) {
    if (as[0] == as[1] || as[1] == as[2] || as[0] == as[2]) return false;
    return as[1] > max(as[0], as[2]) || as[1] < min(as[0], as[2]);
}

void printvec(vi& x, int size = 0) {
    cout << x.front();
    for (int i = 1; i < (size == 0 ? x.size() : size); i++) {
        cout << " " << x[i];
    }
    cout << endl;
}

int main() {
    vi as(7);
    for (int i = 0; i < 7; i++) {
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    do {
        int ok = 1;
        for (int i = 0; i < 5; i++) {
            if (!is_kadomatsu({as[i], as[i + 1], as[i + 2]}) || as[i] >= as[i + 2]) {
                ok = 0;
            }
        }
        if (ok) {
            cout << "YES" << endl;
            // printvec(as);
            return 0;
        }
    } while (next_permutation(as.begin(), as.end()));

    cout << "NO" << endl;
}
0