結果

問題 No.629 グラフの中に眠る門松列
ユーザー ssmkzk
提出日時 2019-06-27 13:12:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 47 ms / 4,000 ms
コード長 667 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-06-27 16:15:31
合計ジャッジ時間 2,929 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

for i in range(M):
    node1, node2 = map(int, input().split())
    conect_l[node1 - 1].append(l[node1 - 1] - l[node2 - 1])
    conect_l[node2 - 1].append(l[node2 - 1] - l[node1 - 1])

# print(conect_l)
for i in range(N):
    s = set(conect_l[i])
    ck = list(s)
    posi_n = 0
    nega_n = 0
    # print(ck)
    for l_i in ck:
        if l_i > 0:
            posi_n += 1
        if l_i < 0:
            nega_n += 1
    if posi_n >= 2:
        print("YES")
        sys.exit()
    if nega_n >= 2:
        print("YES")
        sys.exit()

print("NO")
0