結果
| 問題 |
No.867 避難経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-08 20:14:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 3,678 bytes |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 17,952 KB |
| 最終ジャッジ日時 | 2024-06-27 15:12:02 |
| 合計ジャッジ時間 | 39,188 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 1 -- * 30 |
ソースコード
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)