結果
問題 | No.867 避難経路 |
ユーザー | IJKTanabe |
提出日時 | 2019-09-17 21:12:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,811 bytes |
コンパイル時間 | 1,386 ms |
コンパイル使用メモリ | 86,664 KB |
実行使用メモリ | 240,712 KB |
最終ジャッジ日時 | 2023-09-21 20:16:57 |
合計ジャッジ時間 | 35,436 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 137 ms
77,404 KB |
testcase_01 | AC | 142 ms
77,168 KB |
testcase_02 | AC | 134 ms
77,068 KB |
testcase_03 | AC | 149 ms
77,196 KB |
testcase_04 | AC | 131 ms
76,984 KB |
testcase_05 | AC | 147 ms
77,180 KB |
testcase_06 | AC | 129 ms
77,004 KB |
testcase_07 | AC | 127 ms
77,128 KB |
testcase_08 | AC | 132 ms
77,184 KB |
testcase_09 | AC | 170 ms
77,172 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1,964 ms
78,284 KB |
testcase_12 | AC | 4,359 ms
79,976 KB |
testcase_13 | AC | 2,523 ms
78,828 KB |
testcase_14 | AC | 1,671 ms
78,124 KB |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
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 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
ソースコード
def hinan_keiro(H, W, gy, gx, org_grid, queries): H = H + 2 W = W + 2 goal = (gy * W) + gx result = [] for query in queries: sy, sx, k = query start = (sy * W) + sx k = k**2 # initialize calc grid calc_grid = [0]*W for row in org_grid: calc_grid += [0] + list(map(lambda val: val + k, row)) + [0] calc_grid += [0]*W # initialize count count = calc_grid[start] - 1 calc_grid[start] = 1 # initialize decrease points dec_points = tuple([start]) while calc_grid[goal] != 0: # debug ----- # for r in range(0, H): # print(calc_grid[r * W:r * W + W]) # input() # ----- # copy decrease points to buffer buffer = set(dec_points) for point in dec_points: calc_grid[point] -= 1 if calc_grid[point] == 0: buffer.remove(point) buffer |= set([point - 1, point + 1, point - W, point + W]) dec_points = tuple(buffer) count += 1 result.append(count) return result if __name__ == '__main__': H, W = map(int, input().split(' ')) gy, gx = map(int, input().split(' ')) grid = tuple([ tuple(map(int, input().split(' '))) for i in range(H)]) Q = int(input()) queries = tuple([ tuple(map(int, input().split(' '))) for i in range(Q)]) # import time # start_time = time.time() result = hinan_keiro(H, W, gy, gx, grid, queries) for i in result: print(i) # process_time = time.time() - start_time # print('process_time = ' + str(process_time))