結果
問題 |
No.629 グラフの中に眠る門松列
|
ユーザー |
|
提出日時 | 2019-06-25 19:47:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 788 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 108,648 KB |
最終ジャッジ日時 | 2024-06-23 06:08:09 |
合計ジャッジ時間 | 19,694 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 15 TLE * 1 -- * 20 |
ソースコード
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")