結果

問題 No.715 集合と二人ゲーム
ユーザー fukafukatanifukafukatani
提出日時 2019-02-09 11:33:04
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,462 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 158,028 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-14 11:07:09
合計ジャッジ時間 8,806 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,900 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 9 ms
4,380 KB
testcase_05 AC 12 ms
4,376 KB
testcase_06 AC 13 ms
4,380 KB
testcase_07 AC 19 ms
4,380 KB
testcase_08 AC 25 ms
4,376 KB
testcase_09 AC 30 ms
4,376 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 40 ms
4,376 KB
testcase_12 AC 52 ms
4,376 KB
testcase_13 AC 58 ms
4,380 KB
testcase_14 AC 65 ms
4,376 KB
testcase_15 AC 78 ms
4,380 KB
testcase_16 AC 81 ms
4,376 KB
testcase_17 AC 71 ms
4,376 KB
testcase_18 AC 103 ms
4,376 KB
testcase_19 AC 118 ms
4,376 KB
testcase_20 AC 107 ms
4,380 KB
testcase_21 AC 134 ms
4,376 KB
testcase_22 AC 155 ms
4,380 KB
testcase_23 AC 164 ms
4,380 KB
testcase_24 AC 189 ms
4,376 KB
testcase_25 AC 183 ms
4,380 KB
testcase_26 AC 179 ms
4,380 KB
testcase_27 AC 209 ms
4,376 KB
testcase_28 AC 251 ms
4,376 KB
testcase_29 AC 259 ms
4,376 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
権限があれば一括ダウンロードができます

ソースコード

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 max_elem = *mountains.iter().max().unwrap();
    let mut mem = vec![-1; max_elem + 1];
    mem[0] = 0;
    mem[1] = 1;
    // println!("{:?}", mountains);
    // println!("{:?}", mem);
    for m in 2..max_elem + 1 {
        let mut s = BTreeSet::new();
        s.insert(mem[m - 2]);
        if m > 2 {
            for i in 0..m - 3 + 1 {
                s.insert(mem[i] ^ mem[m - i - 3]);
            }
        }
        let mut res = 0;
        while s.contains(&res) {
            res += 1;
        }
        mem[m] = res;
    }
    let result = mountains.iter().fold(0, |s, &x| s ^ mem[x]);
    if result == 0 {
        println!("Second");
    } else {
        println!("First");
    }
}
0