#abc297c. C - PC on the Table

C - PC on the Table

Score : 300300 points

问题描述

为了在自己的房间中放置多台电脑,Takahashi 决定编写一段代码来计算他能在房间里放置多少台电脑。

给定 HH 个长度为 WW 的字符串 S1,S2,,SHS_1, S_2, \ldots, S_H,每个字符串由.T组成。

Takahashi 可以执行以下操作任意次数(包括零次):

  • 选择满足 1iH1\leq i \leq H1jW11 \leq j \leq W-1 的整数,使得 SiS_i 中的第 jj 个字符和第 (j+1)(j+1) 个字符均为 T。将 SiS_i 的第 jj 个字符替换为 P,并将第 (j+1)(j+1) 个字符替换为 C

他试图最大化执行该操作的次数。找出可能得到的结果字符串 S1,S2,,SHS_1, S_2, \ldots, S_H

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Planning to place many PCs in his room, Takahashi has decided to write a code that finds how many PCs he can place in his room.

You are given HH strings S1,S2,,SHS_1,S_2,\ldots,S_H, each of length WW, consisting of . and T.

Takahashi may perform the following operation any number of times (possibly zero):

  • Choose integers satisfying 1iH1\leq i \leq H and 1jW11 \leq j \leq W-1 such that the jj-th and (j+1)(j+1)-th characters of SiS_i are both T. Replace the jj-th character of SiS_i with P, and (j+1)(j+1)-th with C.

He tries to maximize the number of times he performs the operation. Find possible resulting S1,S2,,SHS_1,S_2,\ldots,S_H.

Constraints

  • 1H1001\leq H \leq 100
  • 2W1002\leq W \leq 100
  • HH and WW are integers.
  • SiS_i is a string of length WW consisting of . and T.

Input

The input is given from Standard Input in the following format:

HH WW

S1S_1

S2S_2

\vdots

SHS_H

Output

Print a sequence of strings, S1,S2,,SHS_1,S_2,\ldots,S_H, separated by newlines, possibly resulting from maximizing the number of times he performs the operation.

If multiple solutions exist, print any of them.

Sample Input 1

2 3
TTT
T.T

Sample Output 1

PCT
T.T

He can perform the operation at most once.

For example, an operation with (i,j)=(1,1)(i,j)=(1,1) makes S1S_1 PCT.

Sample Input 2

3 5
TTT..
.TTT.
TTTTT

Sample Output 2

PCT..
.PCT.
PCTPC

update @ 2024/3/10 12:20:15

}