結果

問題 No.360 増加門松列
ユーザー satanicsatanic
提出日時 2016-04-17 23:25:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 66,104 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 18:36:24
合計ジャッジ時間 2,010 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

int max3(int a, int b, int c){
    return std::max(a, std::max(b, c));
}
int min3(int a, int b, int c){
    return std::min(a, std::min(b, c));
}
bool diff3(int a, int b, int c){
    return (a!=b && b!=c && c!=a);
}
bool isZoukaKadomatsu(int a, int b, int c){
    return (diff3(a, b, c) && a<c && (b==max3(a, b, c) || b==min3(a, b, c)));
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    std::vector<int> d(7);
    for(auto& i : d){
        std::cin >> i;
    }
    std::sort(d.begin(), d.end());
    do{
        bool flag=true;
        for(int i=0; i<5; ++i){
            if(!isZoukaKadomatsu(d[i], d[i+1], d[i+2])){
                flag=false;
                break;
            }
        }
        if(flag){
            std::cout << "YES\n";
            return 0;
        }
    }while(std::next_permutation(d.begin(), d.end()));
    std::cout << "NO\n";
    return 0;
}
0