結果

問題 No.629 グラフの中に眠る門松列
ユーザー 👑 Kazun
提出日時 2021-01-07 18:46:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 4,000 ms
コード長 571 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-11-09 01:17:04
合計ジャッジ時間 4,416 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

N,M=map(int,input().split())
A=[0]+list(map(int,input().split()))

Up  =[[] for _ in range(N+1)]
Down=[[] for _ in range(N+1)]

for _ in range(M):
    u,v=map(int,input().split())
    if A[u]>A[v]:
        Up[v].append(u)
        Down[u].append(v)
    elif A[u]<A[v]:
        Up[u].append(v)
        Down[v].append(u)

F=0
for i in range(1,N+1):
    for p,q in combinations(Up[i],r=2):
        if A[p]!=A[q]:
            F=1

    for p,q in combinations(Down[i],r=2):
        if A[p]!=A[q]:
            F=1

print("YES" if F else "NO")
0