結果
問題 | No.659 徘徊迷路 |
ユーザー | maspy |
提出日時 | 2020-03-07 02:21:13 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 550 ms / 2,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 44,872 KB |
最終ジャッジ日時 | 2024-04-22 11:44:49 |
合計ジャッジ時間 | 11,399 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 544 ms
44,108 KB |
testcase_01 | AC | 543 ms
44,624 KB |
testcase_02 | AC | 550 ms
44,500 KB |
testcase_03 | AC | 541 ms
44,756 KB |
testcase_04 | AC | 542 ms
44,872 KB |
testcase_05 | AC | 540 ms
44,624 KB |
testcase_06 | AC | 543 ms
44,108 KB |
testcase_07 | AC | 541 ms
44,616 KB |
testcase_08 | AC | 544 ms
44,756 KB |
testcase_09 | AC | 542 ms
44,244 KB |
testcase_10 | AC | 540 ms
44,624 KB |
testcase_11 | AC | 540 ms
44,744 KB |
testcase_12 | AC | 539 ms
44,656 KB |
testcase_13 | AC | 543 ms
44,752 KB |
testcase_14 | AC | 538 ms
44,488 KB |
testcase_15 | AC | 546 ms
44,360 KB |
testcase_16 | AC | 540 ms
44,616 KB |
ソースコード
#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np # %% R, C, T = map(int, readline().split()) Sy, Sx = map(int, readline().split()) Gy, Gx = map(int, readline().split()) B = ''.join(read().decode().split()) # %% N = R * C graph = [[] for _ in range(N)] mat = np.zeros((N,N)) for i in range(N): if B[i] == '#': continue deg = 0 for dx in [1, -1, -C, C]: if B[i + dx] == '.': deg += 1 if deg == 0: mat[i, i] = 1.0 else: p = 1 / deg for dx in [1, -1, -C, C]: if B[i + dx] == '.': mat[i, i + dx] = 1 / deg # %% A = np.linalg.matrix_power(mat, T) S = Sy * C + Sx G = Gy * C + Gx print(A[S,G])