結果
問題 |
No.1065 電柱 / Pole (Easy)
|
ユーザー |
|
提出日時 | 2020-05-29 21:48:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 584 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 122,532 KB |
最終ジャッジ日時 | 2024-11-06 03:44:16 |
合計ジャッジ時間 | 77,461 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 37 TLE * 9 |
ソースコード
from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix import sys input = sys.stdin.readline int1 = lambda x: int(x) - 1 N, M = map(int, input().split()) X, Y = map(int1, input().split()) P = [tuple(map(int, input().split())) for _ in range(N)] length, frm, to = [.0] * M, [0] * M, [0] * M for i in range(M): p, q = map(int1, input().split()) length[i] = ((P[p][0] - P[q][0]) ** 2 + (P[p][1] - P[q][1]) ** 2) ** .5 frm[i] = p to[i] = q matr = csr_matrix((length, (frm, to)), shape=(N, N)) print(dijkstra(matr, indices=X, directed=False)[Y])