結果

問題 No.587 七対子
ユーザー phspls
提出日時 2020-02-21 21:05:22
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 17,755 ms
コンパイル使用メモリ 388,820 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 20:04:01
合計ジャッジ時間 13,118 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let s: &str = s.trim();
    let mut c2c: HashMap<char, usize> = HashMap::new();
    s.chars().for_each(|c| {
        if let Some(x) = c2c.get_mut(&c) {
            *x += 1;
        } else {
            c2c.insert(c, 1);
        }
    });

    if c2c.len() != 7 || c2c.iter().filter(|pair| *pair.1 != 2).count() != 1 {
        println!("Impossible");
    } else  {
        println!("{}", c2c.iter().find(|pair| *pair.1 == 1).map(|pair| pair.0).unwrap());
    }
}
0