#abc328d. D - Take ABC
D - Take ABC
Score : points
问题描述
你将得到一个由三个不同字符组成的字符串 :A
、B
和 C
。
只要 中包含连续子串 ABC
,就重复执行以下操作:
从 中移除最左边出现的子串
ABC
。
在执行上述过程后,打印最终的字符串 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a string consisting of three different characters: A
, B
, and C
.
As long as contains the string ABC
as a consecutive substring, repeat the following operation:
Remove the leftmost occurrence of the substring
ABC
from .
Print the final string after performing the above procedure.
Constraints
- is a string of length between and , inclusive, consisting of the characters
A
,B
, andC
.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
BAABCBCCABCAC
Sample Output 1
BCAC
For the given string BAABCBCCABCAC
, the operations are performed as follows.
- In the first operation, the
ABC
from the -rd to the -th character inBAABCBCCABCAC
is removed, resulting inBABCCABCAC
. - In the second operation, the
ABC
from the -nd to the -th character inBABCCABCAC
is removed, resulting inBCABCAC
. - In the third operation, the
ABC
from the -rd to the -th character inBCABCAC
is removed, resulting inBCAC
.
Therefore, the final is BCAC
.
Sample Input 2
ABCABC
Sample Output 2
In this example, the final is an empty string.
Sample Input 3
AAABCABCABCAABCABCBBBAABCBCCCAAABCBCBCC
Sample Output 3
AAABBBCCC
update @ 2024/3/10 01:52:49