結果

問題 No.629 グラフの中に眠る門松列
ユーザー lemonlemon
提出日時 2021-05-16 13:42:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-10-04 17:56:28
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 6
other WA * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()
ntp = lambda: tuple(map(int, stdin.readline().split()))
mod = 10 * 9 + 7
inf = 2 << 60

n, m = na()
A = na()
G = [[] for _ in range (n)]


for _ in range(m):
    u, v = na()
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
print(G)

for i in range(n):
    up = 0
    dn = 0
    num = set()
    for g in G[i]:
        if not(A[g] in num):
            if A[g] < A[i]:
                dn += 1
            if A[g] > A[i]:
                up += 1
            num.add(A[g])
    if up > 1 or dn > 1:
        print('YES')
        exit()

print('NO')
0