結果

問題 No.8116 TCP ソート
ユーザー atcoder8
提出日時 2025-04-01 21:30:21
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 18,563 ms
コンパイル使用メモリ 386,868 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-16 19:41:33
合計ジャッジ時間 17,027 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let num_c = count_char(&s, 'C');
    let num_p = count_char(&s, 'P');
    let num_t = count_char(&s, 'T');

    if num_c == 0 {
        println!("{}{}", "P".repeat(num_p), "T".repeat(num_t))
    } else {
        println!(
            "{}{}{}",
            "T".repeat(num_t),
            "C".repeat(num_c),
            "P".repeat(num_p)
        )
    }
}

fn count_char(s: &str, ch: char) -> usize {
    s.chars().filter(|&c| c == ch).count()
}
0