結果

問題 No.629 グラフの中に眠る門松列
ユーザー titiatitia
提出日時 2024-06-10 03:51:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 4,000 ms
コード長 544 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 69,636 KB
最終ジャッジ日時 2024-12-31 12:56:37
合計ジャッジ時間 3,814 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
E=[[] for i in range(N)]

for i in range(M):
    x,y=map(int,input().split())
    x-=1
    y-=1
    E[x].append(y)
    E[y].append(x)

for i in range(N):
    a=A[i]

    for to in E[i]:
        b=A[to]
        for toto in E[to]:
            c=A[toto]

            if a<b and b>c and a!=c:
                print("YES")
                exit()
            if a>b and b<c and a!=c:
                print("YES")
                exit()

print("NO")
0