結果

問題 No.629 グラフの中に眠る門松列
ユーザー wajima_wataruwajima_wataru
提出日時 2018-01-05 22:01:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 28 ms / 4,000 ms
コード長 537 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 8,388 KB
最終ジャッジ日時 2023-08-24 20:46:03
合計ジャッジ時間 2,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,108 KB
testcase_01 AC 16 ms
7,892 KB
testcase_02 AC 15 ms
8,240 KB
testcase_03 AC 16 ms
8,240 KB
testcase_04 AC 15 ms
8,232 KB
testcase_05 AC 15 ms
8,132 KB
testcase_06 AC 15 ms
7,824 KB
testcase_07 AC 15 ms
7,940 KB
testcase_08 AC 15 ms
7,820 KB
testcase_09 AC 15 ms
8,288 KB
testcase_10 AC 16 ms
8,156 KB
testcase_11 AC 16 ms
8,180 KB
testcase_12 AC 15 ms
8,176 KB
testcase_13 AC 15 ms
8,160 KB
testcase_14 AC 15 ms
7,740 KB
testcase_15 AC 16 ms
8,112 KB
testcase_16 AC 15 ms
8,236 KB
testcase_17 AC 16 ms
8,248 KB
testcase_18 AC 15 ms
8,124 KB
testcase_19 AC 16 ms
8,100 KB
testcase_20 AC 16 ms
7,800 KB
testcase_21 AC 19 ms
8,332 KB
testcase_22 AC 18 ms
8,316 KB
testcase_23 AC 18 ms
8,316 KB
testcase_24 AC 26 ms
8,112 KB
testcase_25 AC 25 ms
7,800 KB
testcase_26 AC 28 ms
8,276 KB
testcase_27 AC 26 ms
8,236 KB
testcase_28 AC 18 ms
7,936 KB
testcase_29 AC 24 ms
8,236 KB
testcase_30 AC 26 ms
8,260 KB
testcase_31 AC 26 ms
8,388 KB
testcase_32 AC 26 ms
8,220 KB
testcase_33 AC 27 ms
8,356 KB
testcase_34 AC 24 ms
8,348 KB
testcase_35 AC 23 ms
8,328 KB
testcase_36 AC 26 ms
8,224 KB
testcase_37 AC 24 ms
8,228 KB
testcase_38 AC 26 ms
8,272 KB
testcase_39 AC 23 ms
8,264 KB
testcase_40 AC 20 ms
8,272 KB
testcase_41 AC 20 ms
8,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
a = list(map(int, input().split()))
g = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    if not a[u - 1] == a[v - 1]:
        g[u - 1].append(a[v - 1])
        g[v - 1].append(a[u - 1])
for i, n in enumerate(g):
    ns = list(set(g[i]))
    length = len(ns)
    if length > 2:
        print('YES')
        exit()
    elif length == 2:
        if (ns[0] < a[i] and ns[1] < a[i]) or (ns[0] > a[i] and ns[1] > a[i]):
            print('YES')
            exit()
print('NO')
0