結果

問題 No.629 グラフの中に眠る門松列
ユーザー lloyzlloyz
提出日時 2022-08-15 16:12:37
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 720 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 78,436 KB
最終ジャッジ日時 2024-04-10 03:47:13
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,868 KB
testcase_01 AC 39 ms
52,820 KB
testcase_02 AC 39 ms
52,820 KB
testcase_03 AC 38 ms
53,280 KB
testcase_04 AC 39 ms
52,404 KB
testcase_05 AC 39 ms
54,056 KB
testcase_06 AC 39 ms
52,680 KB
testcase_07 AC 39 ms
53,828 KB
testcase_08 AC 39 ms
52,580 KB
testcase_09 AC 39 ms
52,884 KB
testcase_10 AC 38 ms
53,324 KB
testcase_11 AC 39 ms
53,196 KB
testcase_12 AC 39 ms
52,516 KB
testcase_13 AC 38 ms
53,216 KB
testcase_14 AC 39 ms
52,604 KB
testcase_15 AC 39 ms
52,616 KB
testcase_16 AC 38 ms
53,012 KB
testcase_17 AC 39 ms
52,336 KB
testcase_18 AC 38 ms
52,692 KB
testcase_19 AC 38 ms
52,692 KB
testcase_20 RE -
testcase_21 AC 61 ms
66,132 KB
testcase_22 AC 53 ms
63,368 KB
testcase_23 AC 60 ms
64,748 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
edge = []
for _ in range(m):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    if u > v:
        u, v = v, u
    edge.append((u, v))

for i in range(m):
    u1, v1 = edge[i]
    for j in range(i + 1, m):
        u2, v2 = edge[j]
        if u1 == u2:
            x, y, z = A[v1], A[u1], A[v2]
        elif u1 == v2:
            x, y, z = A[v1], A[u1], A[u2]
        elif v1 == u2:
            x, y, z = A[u1], A[v1], A[v2]
        elif v1 == v2:
            x, y, z = A[u1], A[v1], A[u2]
        if x == y or x == z or y == z:
            continue
        if x < y > z or x > y < z:
            print("YES")
            exit()
print("NO")
0