AtCoder Grand Contest 036
翻译中…
Problem Statement
翻译中…
Given is a string $S$ consisting of A,B, and C.
翻译中…
Consider the (not necessarily contiguous) subsequences $x$ of $S$ that satisfy all of the following conditions:
翻译中…
A,B, andCall occur the same number of times in$x$.- No two adjacent characters in
$x$are the same.
翻译中…
Among these subsequences, find one of the longest. Here a subsequence of $S$ is a string obtained by deleting zero or more characters from $S$.
翻译中…
Constraints
翻译中…
$1 \leq |S| \leq 10^6$$S$consists ofA,B, andC.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
S
翻译中…
Output
翻译中…
Print one longest subsequence that satisfies the conditions. If multiple solutions exist, any of them will be accepted.
翻译中…
样例
Input #1
ABBCBCAB
Output #1
ACBCAB
Consider the subsequence `ACBCAB` of $S$. It satisfies the conditions and is one of the longest with these properties, along with `ABCBCA`. On the other hand, the subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions.
Input #2
ABABABABACACACAC
Output #2
BABCAC
Input #3
ABCABACBCBABABACBCBCBCBCBCAB
Output #3
ACABACABABACBCBCBCBCA
Input #4
AAA
Output #4
It is possible that only the empty string satisfies the condition.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。