結果

問題 No.629 グラフの中に眠る門松列
ユーザー ysys
提出日時 2018-01-05 21:58:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 4,000 ms
コード長 600 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,884 KB
実行使用メモリ 8,648 KB
最終ジャッジ日時 2023-08-24 20:44:07
合計ジャッジ時間 2,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,236 KB
testcase_01 AC 15 ms
7,900 KB
testcase_02 AC 16 ms
8,252 KB
testcase_03 AC 16 ms
8,188 KB
testcase_04 AC 16 ms
8,236 KB
testcase_05 AC 15 ms
8,196 KB
testcase_06 AC 15 ms
7,760 KB
testcase_07 AC 15 ms
7,828 KB
testcase_08 AC 15 ms
7,788 KB
testcase_09 AC 15 ms
8,196 KB
testcase_10 AC 15 ms
8,184 KB
testcase_11 AC 15 ms
8,236 KB
testcase_12 AC 15 ms
8,276 KB
testcase_13 AC 15 ms
8,148 KB
testcase_14 AC 15 ms
7,768 KB
testcase_15 AC 16 ms
8,104 KB
testcase_16 AC 15 ms
8,240 KB
testcase_17 AC 15 ms
8,292 KB
testcase_18 AC 15 ms
8,204 KB
testcase_19 AC 16 ms
8,244 KB
testcase_20 AC 15 ms
7,728 KB
testcase_21 AC 137 ms
8,332 KB
testcase_22 AC 18 ms
8,312 KB
testcase_23 AC 19 ms
8,448 KB
testcase_24 AC 26 ms
8,340 KB
testcase_25 AC 36 ms
8,240 KB
testcase_26 AC 93 ms
8,216 KB
testcase_27 AC 28 ms
8,500 KB
testcase_28 AC 17 ms
8,232 KB
testcase_29 AC 24 ms
8,428 KB
testcase_30 AC 29 ms
8,552 KB
testcase_31 AC 28 ms
8,484 KB
testcase_32 AC 27 ms
8,624 KB
testcase_33 AC 30 ms
8,648 KB
testcase_34 AC 24 ms
8,468 KB
testcase_35 AC 23 ms
8,452 KB
testcase_36 AC 27 ms
8,544 KB
testcase_37 AC 25 ms
8,476 KB
testcase_38 AC 27 ms
8,592 KB
testcase_39 AC 24 ms
8,524 KB
testcase_40 AC 21 ms
8,280 KB
testcase_41 AC 20 ms
8,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


for k in range(N):
    for i in G[k]:
        if a[i] > a[k]:
            for j in G[k]:
                if a[i] != a[j] and a[j] > a[k]:
                    print("YES")
                    sys.exit()

        elif a[i] < a[k]:
            for j in G[k]:
                if a[i] != a[j] and a[j] < a[k]:
                    print("YES")
                    sys.exit()

print("NO")
0