結果

問題 No.629 グラフの中に眠る門松列
コンテスト
ユーザー 👑 Kazun
提出日時 2021-01-07 18:46:07
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 53 ms / 4,000 ms
+ 503µs
コード長 571 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 63 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 83,688 KB
最終ジャッジ日時 2026-09-21 15:34:35
合計ジャッジ時間 3,570 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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