結果

問題 No.629 グラフの中に眠る門松列
ユーザー dazydazy
提出日時 2018-05-13 22:05:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 4,000 ms
コード長 1,367 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 145,768 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-09-10 19:34:01
合計ジャッジ時間 3,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,272 KB
testcase_01 AC 3 ms
7,268 KB
testcase_02 AC 3 ms
7,340 KB
testcase_03 AC 3 ms
7,340 KB
testcase_04 AC 3 ms
7,280 KB
testcase_05 AC 4 ms
7,296 KB
testcase_06 AC 4 ms
7,416 KB
testcase_07 AC 4 ms
7,296 KB
testcase_08 AC 4 ms
7,344 KB
testcase_09 AC 4 ms
7,320 KB
testcase_10 AC 4 ms
7,464 KB
testcase_11 AC 4 ms
7,240 KB
testcase_12 AC 4 ms
7,464 KB
testcase_13 AC 4 ms
7,220 KB
testcase_14 AC 4 ms
7,228 KB
testcase_15 AC 4 ms
7,284 KB
testcase_16 AC 3 ms
7,280 KB
testcase_17 AC 3 ms
7,272 KB
testcase_18 AC 3 ms
7,336 KB
testcase_19 AC 3 ms
7,244 KB
testcase_20 AC 3 ms
7,272 KB
testcase_21 AC 7 ms
7,256 KB
testcase_22 AC 4 ms
7,500 KB
testcase_23 AC 4 ms
7,316 KB
testcase_24 AC 4 ms
7,388 KB
testcase_25 AC 4 ms
7,556 KB
testcase_26 AC 6 ms
7,388 KB
testcase_27 AC 5 ms
7,292 KB
testcase_28 AC 4 ms
7,320 KB
testcase_29 AC 5 ms
7,236 KB
testcase_30 AC 5 ms
7,316 KB
testcase_31 AC 5 ms
7,424 KB
testcase_32 AC 4 ms
7,316 KB
testcase_33 AC 5 ms
7,296 KB
testcase_34 AC 4 ms
7,236 KB
testcase_35 AC 4 ms
7,480 KB
testcase_36 AC 4 ms
7,572 KB
testcase_37 AC 4 ms
7,252 KB
testcase_38 AC 5 ms
7,332 KB
testcase_39 AC 4 ms
7,300 KB
testcase_40 AC 4 ms
7,232 KB
testcase_41 AC 4 ms
7,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a; i > b; i--)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
typedef long long ll;

int main() {
    fastcin;
    int N, M;
    cin >> N >> M;
    vector<ll> a(N+1);
    REP(i, 1, N+1) cin >> a[i];
    int e[1001][1001] = {};
    REP(i, 0, M) {
        int u, v;
        cin >> u >> v;
        e[u][v] = 1;
        e[v][u] = 1;
    }
    REP(i, 1, N+1) {
        REP(j, 1, N+1) {
            if(e[i][j]) {
                ll c = a[i], s1 = a[j];
                if(c!=s1) {
                    REP(k, 1, N+1) {
                        if(e[i][k]) {
                            ll s2 = a[k];
                            if((s1 < c && c > s2 && s1 != s2)
                                ||(s1 > c && c < s2 && s1 != s2)) {
                                    cout << "YES" << endl;
                                    return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}
0