結果
問題 | No.2946 Puyo |
ユーザー |
|
提出日時 | 2024-11-09 12:30:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 491 ms / 2,000 ms |
コード長 | 602 bytes |
コンパイル時間 | 796 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 135,808 KB |
最終ジャッジ日時 | 2024-11-09 12:30:43 |
合計ジャッジ時間 | 19,051 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
H,W = map(int,input().split()) G = [input() for _ in range(H)] ans = [[G[i][j] for j in range(W)] for i in range(H)] l = [(0,1),(0,-1),(1,0),(-1,0)] for i in range(H): for j in range(W): if ans[i][j] != ".": s = set() stack = [(i,j)] s.add((i,j)) a = ans[i][j] while stack: x,y = stack.pop() for xx,yy in l: if 0 <= x + xx < H and 0 <= y + yy < W: if (x + xx,y + yy) not in s and ans[x + xx][y + yy] == a: s.add((x + xx,y + yy)) stack.append((x + xx,y + yy)) if len(s) > 3: for x,y in s: ans[x][y] = "." for l in ans: print("".join(l))