結果

問題 No.1506 Unbalanced Pocky Game
ユーザー fukafukatanifukafukatani
提出日時 2021-05-14 22:37:02
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 1,207 ms
コンパイル使用メモリ 164,544 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 01:19:31
合計ジャッジ時間 3,305 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 6 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 5 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 5 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 7 ms
6,944 KB
testcase_26 AC 13 ms
6,940 KB
testcase_27 WA -
testcase_28 AC 12 ms
6,944 KB
testcase_29 AC 13 ms
6,940 KB
testcase_30 WA -
testcase_31 AC 13 ms
6,944 KB
testcase_32 AC 13 ms
6,944 KB
testcase_33 WA -
testcase_34 AC 12 ms
6,940 KB
testcase_35 AC 13 ms
6,940 KB
testcase_36 WA -
testcase_37 AC 1 ms
6,944 KB
testcase_38 AC 1 ms
6,944 KB
testcase_39 AC 1 ms
6,940 KB
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 1 ms
6,940 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 WA -
testcase_44 AC 1 ms
6,940 KB
testcase_45 AC 1 ms
6,944 KB
testcase_46 AC 5 ms
6,940 KB
testcase_47 AC 2 ms
6,940 KB
testcase_48 AC 3 ms
6,940 KB
testcase_49 AC 6 ms
6,944 KB
testcase_50 AC 5 ms
6,940 KB
testcase_51 AC 6 ms
6,940 KB
testcase_52 AC 5 ms
6,940 KB
testcase_53 WA -
testcase_54 AC 3 ms
6,940 KB
testcase_55 AC 2 ms
6,940 KB
testcase_56 AC 2 ms
6,940 KB
testcase_57 AC 5 ms
6,940 KB
testcase_58 AC 2 ms
6,940 KB
testcase_59 AC 1 ms
6,944 KB
testcase_60 AC 4 ms
6,944 KB
testcase_61 AC 5 ms
6,940 KB
testcase_62 AC 4 ms
6,940 KB
testcase_63 AC 3 ms
6,940 KB
testcase_64 AC 5 ms
6,940 KB
testcase_65 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
  --> main.rs:19:9
   |
19 |     let n = read::<usize>();
   |         ^ help: if this is intentional, prefix it with an underscore: `_n`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let mut last_grundy = a[0];
    for &anum in a.iter().skip(1) {
        if last_grundy == 0 {
            last_grundy = anum;
        } else if anum < last_grundy {
            last_grundy = anum - 1;
        } else {
            last_grundy = anum;
        }
    }
    if last_grundy == 0 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
0