結果
| 問題 |
No.307 最近色塗る問題多くない?
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2022-11-10 01:32:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 736 bytes |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 19,232 KB |
| 最終ジャッジ日時 | 2024-07-23 06:15:12 |
| 合計ジャッジ時間 | 16,811 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 TLE * 1 -- * 12 |
ソースコード
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
MAP=[list(map(int,input().split())) for i in range(H)]
flag=0
Q=int(input())
for tests in range(Q):
x,y,c=map(int,input().split())
x-=1
y-=1
if flag==1:
MAP[0][0]=c
continue
if MAP[x][y]==c:
continue
Q=[(x,y)]
MAP[x][y]=c
count=1
while Q:
x,y=Q.pop()
for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
if 0<=z<H and 0<=w<W and MAP[z][w]!=c:
MAP[z][w]=c
Q.append((z,w))
count+=1
if count==H*W:
flag=1
if flag==1:
for i in range(H):
print(*[MAP[0][0]]*W)
else:
for i in range(H):
print(*MAP[i])
titia