#abc297c. C - PC on the Table
C - PC on the Table
Score : points
问题描述
为了在自己的房间中放置多台电脑,Takahashi 决定编写一段代码来计算他能在房间里放置多少台电脑。
给定 个长度为 的字符串 ,每个字符串由.
和T
组成。
Takahashi 可以执行以下操作任意次数(包括零次):
- 选择满足 和 的整数,使得 中的第 个字符和第 个字符均为
T
。将 的第 个字符替换为P
,并将第 个字符替换为C
。
他试图最大化执行该操作的次数。找出可能得到的结果字符串 。
以上为通义千问 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 strings , each of length , consisting of .
and T
.
Takahashi may perform the following operation any number of times (possibly zero):
- Choose integers satisfying and such that the -th and -th characters of are both
T
. Replace the -th character of withP
, and -th withC
.
He tries to maximize the number of times he performs the operation. Find possible resulting .
Constraints
- and are integers.
- is a string of length consisting of
.
andT
.
Input
The input is given from Standard Input in the following format:
Output
Print a sequence of strings, , 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 makes PCT
.
Sample Input 2
3 5
TTT..
.TTT.
TTTTT
Sample Output 2
PCT..
.PCT.
PCTPC
update @ 2024/3/10 12:20:15