結果
問題 | No.848 なかよし旅行 |
ユーザー | H3PO4 |
提出日時 | 2021-02-24 18:04:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 614 bytes |
コンパイル時間 | 114 ms |
コンパイル使用メモリ | 11,952 KB |
実行使用メモリ | 103,428 KB |
最終ジャッジ日時 | 2023-10-24 23:49:07 |
合計ジャッジ時間 | 31,549 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,277 ms
71,324 KB |
testcase_01 | AC | 755 ms
53,760 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 730 ms
53,764 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 747 ms
54,212 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 738 ms
53,812 KB |
testcase_25 | WA | - |
testcase_26 | AC | 738 ms
53,620 KB |
testcase_27 | AC | 791 ms
53,556 KB |
testcase_28 | AC | 754 ms
53,620 KB |
testcase_29 | AC | 734 ms
103,428 KB |
ソースコード
import numpy as np from scipy.sparse.csgraph import dijkstra from scipy.sparse import csr_matrix N, M, P, Q, T = map(int, input().split()) P -= 1 Q -= 1 edges = np.array([tuple(map(int, input().split())) for _ in range(M)]).T matr = csr_matrix((edges[2], (edges[:2] - 1)), shape=(N, N)) way_1, way_p, way_q = dijkstra(matr, indices=(0, P, Q), directed=False).astype(int) if way_1[P] + way_1[Q] + way_p[Q] <= T: print(T) exit() possible = ((way_1 + way_p) * 2 <= T) & ((way_1 + way_q) * 2 <= T) if not np.any(possible): print(-1) exit() time = T - np.maximum(way_p, way_q) * 2 print(time.max())