結果

問題 No.629 グラフの中に眠る門松列
ユーザー tobusakanatobusakana
提出日時 2022-11-27 16:14:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 56 ms / 4,000 ms
コード長 587 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 67,012 KB
最終ジャッジ日時 2024-04-14 23:44:52
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,420 KB
testcase_01 AC 37 ms
52,928 KB
testcase_02 AC 38 ms
52,744 KB
testcase_03 AC 38 ms
52,948 KB
testcase_04 AC 38 ms
52,224 KB
testcase_05 AC 37 ms
52,080 KB
testcase_06 AC 38 ms
52,420 KB
testcase_07 AC 38 ms
52,408 KB
testcase_08 AC 38 ms
52,576 KB
testcase_09 AC 38 ms
52,272 KB
testcase_10 AC 38 ms
52,400 KB
testcase_11 AC 38 ms
52,212 KB
testcase_12 AC 38 ms
52,656 KB
testcase_13 AC 38 ms
52,224 KB
testcase_14 AC 38 ms
52,272 KB
testcase_15 AC 38 ms
53,220 KB
testcase_16 AC 39 ms
52,872 KB
testcase_17 AC 38 ms
52,244 KB
testcase_18 AC 37 ms
52,996 KB
testcase_19 AC 38 ms
53,536 KB
testcase_20 AC 37 ms
52,576 KB
testcase_21 AC 42 ms
54,336 KB
testcase_22 AC 42 ms
54,248 KB
testcase_23 AC 43 ms
56,072 KB
testcase_24 AC 46 ms
62,760 KB
testcase_25 AC 50 ms
65,648 KB
testcase_26 AC 53 ms
65,140 KB
testcase_27 AC 54 ms
66,088 KB
testcase_28 AC 40 ms
54,680 KB
testcase_29 AC 47 ms
63,540 KB
testcase_30 AC 52 ms
66,020 KB
testcase_31 AC 53 ms
65,500 KB
testcase_32 AC 50 ms
64,532 KB
testcase_33 AC 56 ms
67,012 KB
testcase_34 AC 50 ms
62,992 KB
testcase_35 AC 50 ms
64,872 KB
testcase_36 AC 50 ms
64,008 KB
testcase_37 AC 50 ms
63,732 KB
testcase_38 AC 48 ms
63,668 KB
testcase_39 AC 48 ms
63,932 KB
testcase_40 AC 54 ms
64,804 KB
testcase_41 AC 47 ms
62,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
A = list(map(int,readline().split()))
G = [[] for i in range(N)]
for _ in range(M):
    u,v = map(int,readline().split())
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
    
for v in range(N):
    if len(G[v]) < 2:
        continue
    less = set()
    more = set()
    for child in G[v]:
        if A[child] < A[v]:
            less.add(A[child])
        if A[child] > A[v]:
            more.add(A[child])
    if len(less) >= 2 or len(more) >= 2:
        print("YES")
        break
else:
    print("NO")
0