結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,308 KB
testcase_01 AC 15 ms
7,932 KB
testcase_02 AC 16 ms
7,868 KB
testcase_03 AC 16 ms
7,924 KB
testcase_04 AC 17 ms
7,848 KB
testcase_05 AC 16 ms
7,996 KB
testcase_06 AC 16 ms
7,932 KB
testcase_07 AC 15 ms
7,808 KB
testcase_08 AC 15 ms
7,816 KB
testcase_09 AC 15 ms
7,940 KB
testcase_10 AC 16 ms
7,872 KB
testcase_11 AC 16 ms
7,940 KB
testcase_12 AC 15 ms
7,780 KB
testcase_13 AC 16 ms
7,860 KB
testcase_14 AC 16 ms
7,780 KB
testcase_15 AC 16 ms
7,868 KB
testcase_16 AC 16 ms
7,916 KB
testcase_17 AC 16 ms
7,868 KB
testcase_18 AC 16 ms
7,880 KB
testcase_19 AC 16 ms
7,836 KB
testcase_20 AC 15 ms
7,792 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 #

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 in range(1, N + 1):
        for j in range(1, N + 1):
            for k in range(1, N + 1):
                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