結果

問題 No.715 集合と二人ゲーム
ユーザー koba-e964koba-e964
提出日時 2021-12-14 13:26:10
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,903 bytes
コンパイル時間 4,292 ms
コンパイル使用メモリ 151,888 KB
実行使用メモリ 7,692 KB
最終ジャッジ日時 2023-09-30 22:04:40
合計ジャッジ時間 9,632 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 7 ms
4,376 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 9 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 11 ms
4,380 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 12 ms
4,380 KB
testcase_24 AC 14 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 14 ms
4,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 16 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 14 ms
4,380 KB
testcase_33 WA -
testcase_34 AC 15 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 1 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 1 ms
4,376 KB
testcase_50 WA -
testcase_51 AC 109 ms
7,416 KB
testcase_52 AC 107 ms
7,156 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 108 ms
7,428 KB
testcase_56 WA -
testcase_57 AC 98 ms
6,848 KB
testcase_58 WA -
testcase_59 AC 109 ms
7,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

// Tags: dawsons-chess, oeis, nim, octal-game
// ref: http://oeis.org/A002187
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut a = a;
    a.sort();
    let lim = 86;
    let mut dp = vec![0; lim];
    dp[1] = 1;
    for i in 2..lim {
        let mut seen = 1 << dp[i - 2];
        for j in 0..i - 2 {
            let x = dp[j] ^ dp[i - 3 - j];
            seen |= 1 << x;
        }
        let mut mex = 0;
        while (seen & 1 << mex) != 0 { mex += 1; }
        dp[i] = mex;
    }
    let gr = |mut a: usize| -> i32 {
        if a >= lim {
            a = (a - lim + 34) % 34 + lim - 34;
        }
        dp[a]
    };
    let mut last = -1;
    let mut c = 0;
    let mut ans = 0;
    for a in a {
        if last != a {
            ans ^= gr(c);
            c = 1;
            last = a;
        } else {
            c += 1;
        }
    }
    ans ^= gr(c);
    println!("{}", if ans == 0 { "Second" } else { "First" });
}
0