結果

問題 No.24 数当てゲーム
ユーザー iwotiwot
提出日時 2019-04-26 23:27:26
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,058 bytes
コンパイル時間 9,810 ms
コンパイル使用メモリ 153,436 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-16 17:39:10
合計ジャッジ時間 1,968 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `i`
  --> 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
  --> 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

warning: 2 warnings emitted

ソースコード

diff #

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);
}
0