結果

問題 No.307 最近色塗る問題多くない?
ユーザー titiatitia
提出日時 2022-11-10 01:32:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,019 ms / 4,000 ms
コード長 737 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 100,612 KB
最終ジャッジ日時 2023-09-30 12:13:34
合計ジャッジ時間 9,375 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,180 KB
testcase_01 AC 71 ms
71,420 KB
testcase_02 AC 72 ms
71,684 KB
testcase_03 AC 74 ms
71,380 KB
testcase_04 AC 88 ms
77,156 KB
testcase_05 AC 76 ms
75,988 KB
testcase_06 AC 79 ms
76,168 KB
testcase_07 AC 106 ms
77,904 KB
testcase_08 AC 150 ms
78,304 KB
testcase_09 AC 116 ms
77,952 KB
testcase_10 AC 103 ms
77,812 KB
testcase_11 AC 105 ms
77,880 KB
testcase_12 AC 73 ms
71,336 KB
testcase_13 AC 98 ms
77,324 KB
testcase_14 AC 91 ms
77,028 KB
testcase_15 AC 94 ms
77,764 KB
testcase_16 AC 94 ms
77,756 KB
testcase_17 AC 131 ms
78,024 KB
testcase_18 AC 221 ms
79,632 KB
testcase_19 AC 198 ms
78,736 KB
testcase_20 AC 83 ms
76,844 KB
testcase_21 AC 180 ms
78,392 KB
testcase_22 AC 162 ms
79,488 KB
testcase_23 AC 924 ms
99,312 KB
testcase_24 AC 361 ms
80,324 KB
testcase_25 AC 475 ms
85,452 KB
testcase_26 AC 933 ms
100,280 KB
testcase_27 AC 101 ms
77,712 KB
testcase_28 AC 162 ms
79,332 KB
testcase_29 AC 88 ms
77,052 KB
testcase_30 AC 1,019 ms
100,612 KB
testcase_31 AC 118 ms
78,180 KB
testcase_32 AC 109 ms
78,104 KB
testcase_33 AC 114 ms
78,448 KB
testcase_34 AC 101 ms
77,932 KB
testcase_35 AC 112 ms
77,948 KB
権限があれば一括ダウンロードができます

ソースコード

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