結果

問題 No.715 集合と二人ゲーム
ユーザー fukafukatanifukafukatani
提出日時 2019-02-09 14:52:13
言語 Rust
(1.72.1)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,463 bytes
コンパイル時間 730 ms
コンパイル使用メモリ 151,432 KB
実行使用メモリ 11,800 KB
最終ジャッジ日時 2023-09-14 11:43:53
合計ジャッジ時間 3,774 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 4 ms
4,380 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,380 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 6 ms
4,376 KB
testcase_28 AC 6 ms
4,376 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 8 ms
4,380 KB
testcase_31 AC 8 ms
4,376 KB
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 8 ms
4,376 KB
testcase_34 AC 7 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,384 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,384 KB
testcase_47 AC 1 ms
4,380 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 47 ms
11,688 KB
testcase_51 AC 48 ms
11,792 KB
testcase_52 AC 47 ms
11,680 KB
testcase_53 AC 46 ms
11,544 KB
testcase_54 AC 47 ms
11,612 KB
testcase_55 AC 46 ms
11,756 KB
testcase_56 AC 45 ms
11,284 KB
testcase_57 AC 44 ms
10,756 KB
testcase_58 AC 49 ms
11,652 KB
testcase_59 AC 47 ms
11,800 KB
権限があれば一括ダウンロードができます

ソースコード

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 n: usize = read();
    let mut a: Vec<u64> = read_vec();
    a.sort();
    let mut mountains = Vec::new();
    mountains.push(1);
    for i in 1..n {
        if a[i] == a[i - 1] + 1 {
            let last_elem = mountains.len() - 1;
            mountains[last_elem] += 1;
        } else {
            mountains.push(1);
        }
    }

    let mem = vec![
        0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 0, 5, 2, 2, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4,
        5, 2, 7, 4, 0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 2, 3, 3, 0, 1, 1, 3, 0, 2,
    ];

    let mem_cycle = vec![
        1, 1, 0, 4, 5, 3, 7, 4, 8, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 9, 3, 3, 0, 1,
        1, 3, 0, 2,
    ];
    let grundy = |i| {
        if i < mem.len() {
            mem[i]
        } else {
            mem_cycle[(i - mem.len()) % mem_cycle.len()]
        }
    };

    let result = mountains.iter().fold(0, |s, &x| s ^ grundy(x));
    if result == 0 {
        println!("Second");
    } else {
        println!("First");
    }
}
0