結果

問題 No.669 対決!!! 飲み比べ
ユーザー fukafukatani
提出日時 2019-02-04 22:42:27
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 905 bytes
コンパイル時間 13,355 ms
コンパイル使用メモリ 381,832 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-26 02:04:25
合計ジャッジ時間 14,934 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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()
}

fn main() {
    let v: Vec<u64> = read_vec();
    let (_, k) = (v[0], v[1]);
    let a: Vec<u64> = read_vec();
    if k == 1 {
        if a.iter().sum::<u64>() % 2 == 1 {
            println!("YES");
        } else {
            println!("NO");
        }
        return;
    }
    let grundy = a.iter().map(|x| x % k).collect::<Vec<_>>();
    let mut nim = 0;
    for num in grundy {
        nim ^= num;
    }
    if nim == 0 {
        println!("NO");
    } else {
        println!("YES");
    }
}
0