結果

問題 No.629 グラフの中に眠る門松列
ユーザー ssmkzkssmkzk
提出日時 2019-06-25 19:47:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 788 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 53,624 KB
最終ジャッジ日時 2023-09-05 10:20:47
合計ジャッジ時間 12,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
31,560 KB
testcase_01 AC 134 ms
31,336 KB
testcase_02 AC 133 ms
31,456 KB
testcase_03 AC 135 ms
31,448 KB
testcase_04 AC 136 ms
29,824 KB
testcase_05 AC 134 ms
29,808 KB
testcase_06 AC 136 ms
29,904 KB
testcase_07 AC 137 ms
29,808 KB
testcase_08 AC 135 ms
29,800 KB
testcase_09 AC 137 ms
30,000 KB
testcase_10 AC 136 ms
29,808 KB
testcase_11 AC 139 ms
31,352 KB
testcase_12 AC 139 ms
29,976 KB
testcase_13 AC 140 ms
29,960 KB
testcase_14 AC 134 ms
29,804 KB
testcase_15 AC 134 ms
29,884 KB
testcase_16 AC 135 ms
29,944 KB
testcase_17 AC 133 ms
29,824 KB
testcase_18 AC 133 ms
29,820 KB
testcase_19 AC 131 ms
29,872 KB
testcase_20 AC 133 ms
29,880 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
import sys

N, M = map(int, input().split())
l = list(map(int, input().split())) 

A = np.zeros((N,N))

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

AA = np.dot(A,A)


for i in range(N):
    for j in range(i + 1, N):
        if AA[i, j] > 0:
            ck = A[i] + A[j]
            for k in range(N):
                if ck[k] == 2:
                    if max(l[k],l[i],l[j]) == l[k] and len(set([l[k],l[i],l[j]])) == 3:
                        print("YES")
                        sys.exit()
                    if min(l[k],l[i],l[j]) == l[k] and len(set([l[k],l[i],l[j]])) == 3:
                        print("YES")
                        sys.exit()
                    
print("NO")
0