結果

問題 No.629 グラフの中に眠る門松列
ユーザー kohei2019
提出日時 2022-02-16 22:45:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 84 ms / 4,000 ms
コード長 561 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-06-29 07:20:38
合計ジャッジ時間 3,896 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
lsa = list(map(int,input().split()))
lsg = [[] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    lsg[a].append(b)
    lsg[b].append(a)

for st in range(N):
    sta = lsa[st]
    for n1 in lsg[st]:
        for n2 in lsg[n1]:
            if sta < lsa[n1] and lsa[n1] > lsa[n2] and sta != lsa[n2]:
                print('YES')
                exit()
            if sta > lsa[n1] and lsa[n1] < lsa[n2] and sta != lsa[n2]:
                print('YES')
                exit()
print('NO')
0