PC on the Table

AtCoder
IDabc297_c
Time2000ms
Memory256MB
Difficulty
> 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 $H$ strings $S_1,S_2,\ldots,S_H$, each of length $W$, consisting of `.` and `T`. Takahashi may perform the following operation any number of times (possibly zero): * Choose integers satisfying $1\leq i \leq H$ and $1 \leq j \leq W-1$ such that the $j$\-th and $(j+1)$\-th characters of $S_i$ are both `T`. Replace the $j$\-th character of $S_i$ with `P`, and $(j+1)$\-th with `C`. He tries to maximize the number of times he performs the operation. Find possible resulting $S_1,S_2,\ldots,S_H$. ## Constraints * $1\leq H \leq 100$ * $2\leq W \leq 100$ * $H$ and $W$ are integers. * $S_i$ is a string of length $W$ consisting of `.` and `T`. ## Input The input is given from Standard Input in the following format: $H$ $W$ $S_1$ $S_2$ $\vdots$ $S_H$ [samples]
Samples
Input #1
2 3
TTT
T.T
Output #1
PCT
T.T

He can perform the operation at most once.
For example, an operation with $(i,j)=(1,1)$ makes $S_1$ `PCT`.
Input #2
3 5
TTT..
.TTT.
TTTTT
Output #2
PCT..
.PCT.
PCTPC
API Response (JSON)
{
  "problem": {
    "name": "PC on the Table",
    "description": {
      "content": "> 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 $H$ strings $S_1,S_2,\\ldots,S_H$, each of length $W$, c",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc297_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "> 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.\n\nYou are given $H$ strings $S_1,S_2,\\ldots,S_H$, each of length $W$, c...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments