結果

問題 No.629 グラフの中に眠る門松列
ユーザー tamato
提出日時 2020-05-12 20:33:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 4,000 ms
コード長 753 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 64,512 KB
最終ジャッジ日時 2024-09-13 21:02:56
合計ジャッジ時間 3,574 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    def fin():
        print("YES")
        exit()

    N, M = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    for v in range(1, N+1):
        a = A[v]
        small = set()
        large = set()
        for u in adj[v]:
            if A[u] < a:
                small.add(A[u])
            elif A[u] > a:
                large.add(A[u])
        if len(small) > 1 or len(large) > 1:
            fin()
            print(v)
    print("NO")


if __name__ == '__main__':
    main()
0