結果

問題 No.629 グラフの中に眠る門松列
ユーザー yansi819
提出日時 2024-05-15 20:04:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 74,104 KB
最終ジャッジ日時 2024-12-20 10:23:29
合計ジャッジ時間 3,849 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 28 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
A = list(map(int, input().split()))
G = [[]] * N
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)

for u in range(N):
    if (len(G[u]) < 2):
        continue
    less = set()
    more = set()
    for v in G[u]:
        if A[v] < A[u]:
            less.add(A[v])
        if A[v] > A[u]:
            more.add(A[v])
    if len(less) >= 2 or len(more) >= 2:
        print("YES")
        break
else:
    print("NO")
0