結果

問題 No.629 グラフの中に眠る門松列
ユーザー H3PO4H3PO4
提出日時 2020-10-14 16:28:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 28 ms / 4,000 ms
コード長 464 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 10,836 KB
実行使用メモリ 8,640 KB
最終ジャッジ日時 2023-09-28 00:39:10
合計ジャッジ時間 2,952 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,156 KB
testcase_01 AC 14 ms
7,852 KB
testcase_02 AC 14 ms
8,080 KB
testcase_03 AC 14 ms
8,304 KB
testcase_04 AC 14 ms
8,272 KB
testcase_05 AC 14 ms
8,220 KB
testcase_06 AC 14 ms
7,780 KB
testcase_07 AC 13 ms
7,880 KB
testcase_08 AC 14 ms
7,780 KB
testcase_09 AC 13 ms
8,216 KB
testcase_10 AC 13 ms
8,272 KB
testcase_11 AC 14 ms
8,152 KB
testcase_12 AC 14 ms
8,152 KB
testcase_13 AC 13 ms
8,208 KB
testcase_14 AC 13 ms
7,780 KB
testcase_15 AC 13 ms
8,204 KB
testcase_16 AC 13 ms
8,296 KB
testcase_17 AC 14 ms
8,284 KB
testcase_18 AC 13 ms
8,300 KB
testcase_19 AC 13 ms
8,112 KB
testcase_20 AC 14 ms
7,900 KB
testcase_21 AC 19 ms
8,324 KB
testcase_22 AC 17 ms
8,272 KB
testcase_23 AC 17 ms
8,308 KB
testcase_24 AC 25 ms
8,364 KB
testcase_25 AC 24 ms
8,360 KB
testcase_26 AC 24 ms
8,320 KB
testcase_27 AC 27 ms
8,480 KB
testcase_28 AC 17 ms
8,232 KB
testcase_29 AC 23 ms
8,444 KB
testcase_30 AC 26 ms
8,516 KB
testcase_31 AC 26 ms
8,640 KB
testcase_32 AC 25 ms
8,592 KB
testcase_33 AC 28 ms
8,504 KB
testcase_34 AC 23 ms
8,492 KB
testcase_35 AC 23 ms
8,372 KB
testcase_36 AC 26 ms
8,444 KB
testcase_37 AC 23 ms
8,324 KB
testcase_38 AC 26 ms
8,584 KB
testcase_39 AC 23 ms
8,432 KB
testcase_40 AC 20 ms
8,400 KB
testcase_41 AC 19 ms
8,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# O(M + NlogN)程度

int1 = lambda x: int(x) - 1

N, M = map(int, input().split())
A = tuple(map(int1, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int1, input().split())
    G[a].append(b)
    G[b].append(a)

for i, a in enumerate(A):
    st = set(A[x] for x in G[i])
    st.add(a)
    lst = sorted(list(st))
    if len(lst) < 2:
        continue
    if lst[1] < a or lst[-2] > a:
        print('YES')
        exit()
print('NO')
0