結果

問題 No.629 グラフの中に眠る門松列
ユーザー dazydazy
提出日時 2018-05-13 22:02:30
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,367 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 146,292 KB
実行使用メモリ 7,484 KB
最終ジャッジ日時 2023-09-10 19:33:06
合計ジャッジ時間 3,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,484 KB
testcase_01 AC 3 ms
7,352 KB
testcase_02 AC 4 ms
7,348 KB
testcase_03 AC 3 ms
7,224 KB
testcase_04 AC 4 ms
7,224 KB
testcase_05 AC 3 ms
7,420 KB
testcase_06 AC 3 ms
7,304 KB
testcase_07 AC 3 ms
7,300 KB
testcase_08 WA -
testcase_09 AC 4 ms
7,224 KB
testcase_10 AC 4 ms
7,360 KB
testcase_11 AC 3 ms
7,300 KB
testcase_12 AC 3 ms
7,416 KB
testcase_13 AC 3 ms
7,240 KB
testcase_14 AC 4 ms
7,224 KB
testcase_15 AC 4 ms
7,352 KB
testcase_16 AC 3 ms
7,412 KB
testcase_17 AC 4 ms
7,364 KB
testcase_18 AC 4 ms
7,304 KB
testcase_19 AC 3 ms
7,304 KB
testcase_20 AC 3 ms
7,300 KB
testcase_21 WA -
testcase_22 AC 4 ms
7,376 KB
testcase_23 AC 4 ms
7,308 KB
testcase_24 AC 4 ms
7,252 KB
testcase_25 AC 4 ms
7,372 KB
testcase_26 AC 6 ms
7,316 KB
testcase_27 AC 4 ms
7,316 KB
testcase_28 AC 4 ms
7,256 KB
testcase_29 AC 3 ms
7,316 KB
testcase_30 AC 4 ms
7,440 KB
testcase_31 AC 5 ms
7,240 KB
testcase_32 AC 4 ms
7,256 KB
testcase_33 AC 5 ms
7,308 KB
testcase_34 AC 4 ms
7,316 KB
testcase_35 AC 4 ms
7,316 KB
testcase_36 AC 4 ms
7,236 KB
testcase_37 AC 4 ms
7,240 KB
testcase_38 AC 4 ms
7,312 KB
testcase_39 AC 4 ms
7,320 KB
testcase_40 AC 4 ms
7,312 KB
testcase_41 AC 4 ms
7,312 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[j][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