結果
| 問題 | 
                            No.24 数当てゲーム
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-04-26 23:27:26 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 1,058 bytes | 
| コンパイル時間 | 13,829 ms | 
| コンパイル使用メモリ | 384,496 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 07:16:36 | 
| 合計ジャッジ時間 | 12,294 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
warning: unused variable: `i`
  --> src/main.rs:22:9
   |
22 |     for i in 0..turn {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default
warning: variable does not need to be mutable
  --> src/main.rs:14:13
   |
14 |         let mut estimate: Vec<usize> = input.trim().split_whitespace().take(4).map(|n| n.parse().unwrap()).collect();
   |             ----^^^^^^^^
   |             |
   |             help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default
            
            ソースコード
fn main() {
    let mut input = String::new();
    let _ = std::io::stdin().read_line(&mut input);
    let turn: usize = input.trim().parse().unwrap();
    struct Input {
        estimate: Vec<usize>,
        answer: String,
    }
    let get_input = || {
        let mut input = String::new();
        let _ = std::io::stdin().read_line(&mut input);
        let mut estimate: Vec<usize> = input.trim().split_whitespace().take(4).map(|n| n.parse().unwrap()).collect();
        let answer: &str = input.trim().split_whitespace().nth(4).unwrap();
        Input { estimate, answer: answer.to_string() }
    };
    let mut checker = vec![0i32; 10];
    for i in 0..turn {
        let input = get_input();
        if input.answer == "YES" {
            for j in input.estimate {
                checker[j] += 1;
            }
        } else {
            for j in input.estimate {
                checker[j] -= 1;
            }
        }
    }
    let result = checker.iter().enumerate().max_by(|x, y| x.1.cmp(y.1)).unwrap();
    println!("{}", result.0);
}