結果

問題 No.629 グラフの中に眠る門松列
ユーザー convexineq
提出日時 2021-03-03 18:27:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 73,000 KB
最終ジャッジ日時 2024-10-03 07:20:51
合計ジャッジ時間 3,022 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 21 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
*a, = map(int,input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    x,y = map(int,input().split())
    g[x-1].append(y-1)
    g[y-1].append(x-1)
for x in range(n):
    le = set()
    mo = set()
    for v in g[x]:
        if a[v] < a[x]:
            if le and a[v] not in le:
                print("YES")
                exit()
            le.add(a[v])
        if a[v] > a[x]:
            if mo and a[v] not in mo:
                print("YES")
                exit()
print("NO")
0