結果

問題 No.629 グラフの中に眠る門松列
ユーザー GrayCoder
提出日時 2018-01-05 23:06:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 19,968 KB
最終ジャッジ日時 2024-12-23 07:15:07
合計ジャッジ時間 6,891 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 27 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from collections import defaultdict
from collections import Counter
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 in range(1, N + 1):
        for j in range(1, N + 1):
            for k in range(1, N + 1):
                if len(set([i, j, k])) == 3:
                    if a[i] < a[j] > a[k] and a[i] != a[k] or \
                        a[i] > a[j] < a[k] and a[i] != a[k]:
                            print('YES')
                            return
    print('NO')

main()
0