結果

問題 No.629 グラフの中に眠る門松列
ユーザー GrayCoderGrayCoder
提出日時 2018-01-05 23:27:55
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 640 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 25,504 KB
最終ジャッジ日時 2023-08-24 21:17:51
合計ジャッジ時間 6,508 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
25,504 KB
testcase_01 AC 16 ms
8,292 KB
testcase_02 AC 18 ms
8,176 KB
testcase_03 AC 17 ms
8,156 KB
testcase_04 AC 17 ms
8,296 KB
testcase_05 AC 17 ms
8,180 KB
testcase_06 AC 17 ms
8,152 KB
testcase_07 AC 16 ms
8,176 KB
testcase_08 AC 16 ms
8,240 KB
testcase_09 AC 16 ms
8,272 KB
testcase_10 AC 16 ms
8,176 KB
testcase_11 AC 15 ms
8,192 KB
testcase_12 AC 15 ms
8,352 KB
testcase_13 AC 15 ms
8,252 KB
testcase_14 AC 15 ms
8,224 KB
testcase_15 AC 16 ms
8,304 KB
testcase_16 AC 15 ms
8,364 KB
testcase_17 AC 16 ms
8,328 KB
testcase_18 AC 15 ms
8,268 KB
testcase_19 AC 15 ms
8,156 KB
testcase_20 AC 15 ms
8,316 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

def main():
    N, M = map(int, input().split())
    A = tuple(map(int, input().split()))
    UV = tuple(tuple(map(int, input().split())) for _ in [0] * M)

    a = dict()
    for i, j in enumerate(A):
        a[i+1] = j

    edge = [[0 for _ in [0] * (N + 1)] for _ in [0] * (N + 1)]
    for u, v in UV:
        edge[u][v] = edge[v][u] = 1

    for i, j, k in permutations(range(N + 1), 3):
        if edge[i][j] and edge[j][k]:
            if a[i] != a[k]:
                if a[i] < a[j] > a[k] or a[i] > a[j] < a[k]:
                    print('YES')
                    return
    print('NO')

main()
0