結果

問題 No.360 増加門松列
ユーザー hogeover30hogeover30
提出日時 2016-04-17 23:23:13
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 583 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 52,108 KB
最終ジャッジ日時 2023-08-25 18:36:22
合計ジャッジ時間 622 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:5: error: ‘vector’ was not declared in this scope
     vector<int> a(7);
     ^~~~~~
main.cpp:12:5: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:3:1:
+#include <vector>
 using namespace std;
main.cpp:12:5:
     vector<int> a(7);
     ^~~~~~
main.cpp:12:12: error: expected primary-expression before ‘int’
     vector<int> a(7);
            ^~~
main.cpp:13:17: error: ‘a’ was not declared in this scope
     for(int& v: a) cin>>v;
                 ^
main.cpp:14:16: error: ‘a’ was not declared in this scope
     sort(begin(a), end(a));
                ^

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

bool iskadomatsu(int a, int b, int c)
{
    return a!=c and ((b>a and b>c) or (b<a and b<c));
}

int main()
{
    vector<int> a(7);
    for(int& v: a) cin>>v;
    sort(begin(a), end(a));

    do {
        bool ok=true;
        for(int i=0; i<5; ++i) {
            if (!(a[i]<a[i+2] and iskadomatsu(a[i], a[i+1], a[i+2]))) {
                ok=false;
                break;
            }
        }
        if (ok) { cout<<"YES"<<endl; return 0; }
    } while (next_permutation(begin(a), end(a)));
    cout<<"NO"<<endl;
}
0