結果
| 問題 | No.307 最近色塗る問題多くない? |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-11 18:36:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 717 bytes |
| 記録 | |
| コンパイル時間 | 363 ms |
| コンパイル使用メモリ | 82,032 KB |
| 実行使用メモリ | 112,688 KB |
| 最終ジャッジ日時 | 2025-12-11 18:36:35 |
| 合計ジャッジ時間 | 8,468 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 1 -- * 27 |
ソースコード
from collections import deque
h, w = map(int, input().split())
grid = [list(map(int, input().split())) for _ in range(h)]
dy = [-1, 1, 0, 0]
dx = [0, 0, -1, 1]
Q = int(input())
for _ in range(Q):
r, c, x = map(int, input().split())
r -= 1
c -= 1
original = grid[r][c]
if original == x:
continue
q = deque()
q.append((r, c))
grid[r][c] = x
while q:
cy, cx = q.popleft()
for i in range(4):
ny = cy + dy[i]
nx = cx + dx[i]
if 0 <= ny < h and 0 <= nx < w:
if grid[ny][nx] == original:
grid[ny][nx] = x
q.append((ny, nx))
for row in grid:
print(*row)