結果
問題 | No.867 避難経路 |
ユーザー | IJKTanabe |
提出日時 | 2019-09-08 20:16:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,678 bytes |
コンパイル時間 | 264 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 90,540 KB |
最終ジャッジ日時 | 2024-06-27 15:12:29 |
合計ジャッジ時間 | 13,680 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 274 ms
77,568 KB |
testcase_01 | AC | 264 ms
77,332 KB |
testcase_02 | AC | 264 ms
77,104 KB |
testcase_03 | AC | 269 ms
77,056 KB |
testcase_04 | AC | 246 ms
77,044 KB |
testcase_05 | AC | 295 ms
77,440 KB |
testcase_06 | AC | 250 ms
76,964 KB |
testcase_07 | AC | 215 ms
77,056 KB |
testcase_08 | AC | 252 ms
77,268 KB |
testcase_09 | AC | 356 ms
77,348 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
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 | -- | - |
ソースコード
class Point: def __init__ (self, x, y): self.x = x self.y = y def nextPoints(self, x_max, y_max): nexts = [] if self.x > 0: nexts.append(Point(self.x - 1, self.y)) if self.x < x_max: nexts.append(Point(self.x + 1, self.y)) if self.y > 0: nexts.append(Point(self.x, self.y - 1)) if self.y < y_max: nexts.append(Point(self.x, self.y + 1)) return nexts HW = input() if HW != '': H, W = map(int, HW.split(' ')) gy, gx = map(lambda i: int(i) -1 , input().split(' ')) grid = [] for y in range(H): grid.append(list(map(int, input().split(' ')))) grid_org = tuple([tuple(i) for i in grid]) Q = int(input()) debug_print = False elif HW == '': H = 10 W = 10 gy = 2 - 1 gx = 9 - 1 Q = 1 debug_print = True print ('input start x, y, and k') grid_org = ((9, 9, 9, 9, 9, 9, 9, 9, 9, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 9, 9, 9, 9, 9, 9, 1, 9), (9, 9, 0, 9, 9, 9, 9, 9, 1, 9), (9, 9, 1, 9, 9, 9, 9, 9, 1, 9), (9, 9, 1, 1, 1, 1, 1, 1, 1, 9)) result = [] for que in range(Q): sy, sx, k = map(int, input().split()) sy -= 1 sx -= 1 grid = [] for i in range(H): grid.append(list(map(lambda x: x + k**2, grid_org[i]))) count = grid[sy][sx] grid[sy][sx] = 0 if debug_print: print() print('k = ' + str(k)) print('startNum = ' + str(grid[sy][sx])) print ('count = ' + str(count)) while grid[gy][gx] != 0: buffer = [list(i) for i in grid] for y in range(H): for x in range(W): if grid[y][x] <= 0: for p in Point(x,y).nextPoints(W -1, H -1): buffer[p.y][p.x] = grid[p.y][p.x] - 1 count += 1 if debug_print: for y in range(H): for x in range(W): color = '\033[37m' char = str(buffer[y][x]) if y == sy and x == sx: color = '\033[33m' char = 'S' elif y == gy and x == gx: color = '\033[31m' elif buffer[y][x] <= 0: color = '\033[34m' elif buffer[y][x] != grid[y][x]: color = '\033[32m' print(color, end = '') print(char.rjust(5), end = '') print() print('\033[0m') print('count = ' + str(count)) input() grid = tuple([tuple(i) for i in buffer]) result.append(count) for i in result: print(i)