結果
| 問題 | No.24 数当てゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-04-06 13:36:02 | 
| 言語 | Rust (1.83.0 + proconio) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 1,291 bytes | 
| コンパイル時間 | 14,923 ms | 
| コンパイル使用メモリ | 377,920 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2025-01-03 02:41:51 | 
| 合計ジャッジ時間 | 15,822 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
ソースコード
use std::collections::HashSet;
fn _read() -> Vec<(bool, Vec<i8>)> {
    let mut ret: Vec<(bool, Vec<i8>)> = Vec::new();
    let mut _s = String::new();
    std::io::stdin().read_line(&mut _s).ok();
    loop {
        let mut _s = String::new();
        let _len = std::io::stdin().read_line(&mut _s).ok();
        if _len.unwrap() == 0 {
            break;
        }
        let mut _v: Vec<String> = _s
            .split_ascii_whitespace()
            .map(|e| e.trim().to_string())
            .collect();
        let _item: (bool, Vec<i8>) = (
            _v.pop().unwrap() == "YES",
            _v.iter().map(|e| e.trim().parse().ok().unwrap()).collect(),
        );
        ret.push(_item);
    }
    ret
}
fn calc(data: Vec<(bool, Vec<i8>)>) -> i8 {
    let mut _ans: HashSet<i8> = (0..=9).collect();
    for (stat, val) in data {
        let remove_targets: HashSet<i8> = match stat {
            true => &((0..=9).collect::<HashSet<i8>>()) - &(val.iter().cloned().collect()),
            false => val.iter().cloned().collect(),
        };
        for n in remove_targets {
            _ans.remove(&n);
        }
    }
    for n in _ans {
        return n;
    }
    return -1
}
fn main() {
    let data: Vec<(bool, Vec<i8>)> = _read();
    println!("{}", calc(data));
}
            
            
            
        