結果

問題 No.629 グラフの中に眠る門松列
ユーザー FukumotoFukumoto
提出日時 2020-06-08 12:08:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 90 ms / 4,000 ms
コード長 562 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2023-08-26 07:08:39
合計ジャッジ時間 2,917 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,052 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
8,052 KB
testcase_03 AC 16 ms
8,196 KB
testcase_04 AC 15 ms
8,136 KB
testcase_05 AC 16 ms
8,188 KB
testcase_06 AC 16 ms
7,712 KB
testcase_07 AC 15 ms
7,792 KB
testcase_08 AC 15 ms
7,896 KB
testcase_09 AC 15 ms
8,188 KB
testcase_10 AC 15 ms
8,136 KB
testcase_11 AC 16 ms
8,272 KB
testcase_12 AC 15 ms
8,180 KB
testcase_13 AC 16 ms
8,140 KB
testcase_14 AC 16 ms
7,792 KB
testcase_15 AC 16 ms
8,052 KB
testcase_16 AC 16 ms
8,120 KB
testcase_17 AC 16 ms
8,136 KB
testcase_18 AC 16 ms
8,048 KB
testcase_19 AC 16 ms
8,056 KB
testcase_20 AC 16 ms
7,796 KB
testcase_21 AC 90 ms
8,484 KB
testcase_22 AC 20 ms
8,360 KB
testcase_23 AC 59 ms
8,352 KB
testcase_24 AC 27 ms
8,332 KB
testcase_25 AC 59 ms
8,132 KB
testcase_26 AC 66 ms
8,256 KB
testcase_27 AC 30 ms
8,520 KB
testcase_28 AC 18 ms
8,272 KB
testcase_29 AC 26 ms
8,512 KB
testcase_30 AC 29 ms
8,564 KB
testcase_31 AC 30 ms
8,496 KB
testcase_32 AC 28 ms
8,704 KB
testcase_33 AC 36 ms
8,580 KB
testcase_34 AC 25 ms
8,552 KB
testcase_35 AC 25 ms
8,480 KB
testcase_36 AC 30 ms
8,648 KB
testcase_37 AC 29 ms
8,556 KB
testcase_38 AC 30 ms
8,428 KB
testcase_39 AC 25 ms
8,484 KB
testcase_40 AC 23 ms
8,532 KB
testcase_41 AC 22 ms
8,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N, M = list(map(int, input().split()))
a = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
    u, v = list(map(int, input().split()))
    u -= 1; v -= 1
    
    g[u].append(v)
    g[v].append(u)
    
for i in range(N):
    q = [v for v in g[i]]

    for v in q:
        n = [(a[i], a[v], a[u]) for u in g[v] if a[i] != a[v] and a[i] != a[u] and a[v] != a[u] and i != u and v != u]
        for s in n:
            if min(s) == a[v] or max(s) == a[v]: 
                print('YES')
                sys.exit()

print('NO')
0