結果
問題 | No.715 集合と二人ゲーム |
ユーザー |
|
提出日時 | 2021-12-14 13:26:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,903 bytes |
コンパイル時間 | 13,965 ms |
コンパイル使用メモリ | 391,108 KB |
実行使用メモリ | 7,684 KB |
最終ジャッジ日時 | 2024-07-23 15:50:23 |
合計ジャッジ時間 | 17,696 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 31 |
ソースコード
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8macro_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/A002187fn 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" });}