結果

問題 No.548 国士無双
ユーザー cra77756176
提出日時 2022-12-16 19:56:39
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 24,801 ms
コンパイル使用メモリ 399,492 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-16 00:50:35
合計ジャッジ時間 25,902 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: Vec<char> = s.trim().chars().collect();

    let count: Vec<usize> = ('a'..='m')
        .map(|c| s.iter().filter(|&&d| d == c).count())
        .collect();

    if count.iter().all(|&n| n == 1) {
        for c in 'a'..='m' {
            println!("{c}");
        }
    } else if count.iter().filter(|&&n| n == 0).count() == 1 {
        println!(
            "{}",
            ('a'..='m')
                .nth(count.iter().position(|&n| n == 0).unwrap())
                .unwrap()
        );
    } else {
        println!("Impossible");
    }
}
0