問題一覧 > ネタ問題

No.8116 TCP Sort

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 88
作問者 : tatyam
お気に入りにしたユーザー ProblemId : 11445 / 自分の提出
問題文最終更新日: 2025-04-04 10:49:19
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder April Fool Contest 2025 (順位表) の他の問題:

Problem Statement

You are given a string $S$ consisting of C, P, and T. Rearrange the characters of $S$ so that the following $2$ conditions are satisfied, and output the result.

  • Every T in $S$ appears to the left of every C.
  • Every C in $S$ appears to the left of every P.

Input

$S$

  • $S$ is a string of length between $1$ and $100$, inclusive, consisting of C, P, and T.

Output

Output the characters of $S$ rearranged so that the conditions in the problem statement are satisfied. However, if there are multiple rearrangements satisfying the conditions, output the lexicographically smallest one among them.
It can be proved that at least $1$ rearrangement satisfying the conditions exists.

Sample

Sample 1
Input
PCT
Output
TCP

The only rearrangement of PCT satisfying the conditions is TCP, so there is $1$ such rearrangement.

Sample 2
Input
CCTTPPCPCT
Output
TTTCCCCPPP

The only rearrangement of CCTTPPCPCT satisfying the conditions is TTTCCCCPPP, so there is $1$ such rearrangement.

Sample 3
Input
PCPCPCCPCC
Output
CCCCCCPPPP

The only rearrangement of PCPCPCCPCC satisfying the conditions is CCCCCCPPPP, so there is $1$ such rearrangement.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。