結果

問題 No.307 最近色塗る問題多くない?
ユーザー titiatitia
提出日時 2022-11-10 01:32:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 736 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 14,180 KB
最終ジャッジ日時 2023-09-30 12:14:07
合計ジャッジ時間 15,449 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,012 KB
testcase_01 AC 17 ms
7,808 KB
testcase_02 AC 16 ms
7,876 KB
testcase_03 AC 16 ms
7,872 KB
testcase_04 AC 21 ms
8,432 KB
testcase_05 AC 17 ms
7,788 KB
testcase_06 AC 16 ms
7,956 KB
testcase_07 AC 102 ms
8,920 KB
testcase_08 AC 726 ms
9,480 KB
testcase_09 AC 271 ms
8,972 KB
testcase_10 AC 31 ms
8,588 KB
testcase_11 AC 51 ms
8,576 KB
testcase_12 AC 17 ms
7,912 KB
testcase_13 AC 74 ms
8,344 KB
testcase_14 AC 43 ms
8,512 KB
testcase_15 AC 63 ms
8,568 KB
testcase_16 AC 63 ms
8,496 KB
testcase_17 AC 681 ms
8,928 KB
testcase_18 AC 2,347 ms
9,468 KB
testcase_19 AC 1,894 ms
9,496 KB
testcase_20 AC 19 ms
8,556 KB
testcase_21 AC 1,356 ms
9,288 KB
testcase_22 AC 1,125 ms
9,744 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0