結果
問題 | No.715 集合と二人ゲーム |
ユーザー | tubo28 |
提出日時 | 2017-10-04 13:29:14 |
言語 | Rust (1.77.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,850 bytes |
コンパイル時間 | 5,068 ms |
コンパイル使用メモリ | 161,176 KB |
実行使用メモリ | 12,968 KB |
最終ジャッジ日時 | 2023-08-10 23:01:01 |
合計ジャッジ時間 | 9,324 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,760 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 3 ms
4,376 KB |
testcase_03 | AC | 7 ms
4,376 KB |
testcase_04 | AC | 9 ms
4,376 KB |
testcase_05 | AC | 13 ms
4,376 KB |
testcase_06 | AC | 15 ms
4,376 KB |
testcase_07 | AC | 21 ms
4,376 KB |
testcase_08 | AC | 28 ms
4,376 KB |
testcase_09 | AC | 34 ms
4,380 KB |
testcase_10 | AC | 38 ms
4,376 KB |
testcase_11 | AC | 47 ms
4,376 KB |
testcase_12 | AC | 61 ms
4,824 KB |
testcase_13 | AC | 68 ms
4,452 KB |
testcase_14 | AC | 77 ms
5,820 KB |
testcase_15 | AC | 96 ms
4,560 KB |
testcase_16 | AC | 96 ms
4,380 KB |
testcase_17 | AC | 86 ms
6,492 KB |
testcase_18 | AC | 122 ms
4,460 KB |
testcase_19 | AC | 147 ms
6,740 KB |
testcase_20 | AC | 127 ms
5,600 KB |
testcase_21 | AC | 159 ms
5,440 KB |
testcase_22 | AC | 192 ms
8,784 KB |
testcase_23 | AC | 197 ms
7,136 KB |
testcase_24 | AC | 227 ms
7,264 KB |
testcase_25 | AC | 225 ms
10,648 KB |
testcase_26 | AC | 217 ms
8,760 KB |
testcase_27 | AC | 257 ms
9,548 KB |
testcase_28 | AC | 306 ms
11,536 KB |
testcase_29 | AC | 318 ms
12,968 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 | -- | - |
ソースコード
use std::io::*; use std::str::*; fn readw<T: FromStr, R: Read>(s: &mut R) -> Option<T> { let s = s.bytes().map(|c| c.unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect::<String>(); if s.is_empty() { None } else { s.parse::<T>().ok() } } const MAX_M: usize = 1000; fn read<T: FromStr, R: Read>(s: &mut R) -> T { readw(s).unwrap() } fn grundy(n: u32, dp: &mut Vec<Option<u32>>) -> u32 { if let Some(res) = dp[n as usize] { res } else { let res = if n == 1 || n == 0 { n } else { let mut s = vec![false; n as usize + 1]; s[grundy(n - 2, dp) as usize] = true; for i in 0..n-2 { s[(grundy(i, dp) ^ grundy(n - 3 - i, dp)) as usize] = true; } (0..MAX_M).find(|&x| !s[x]).unwrap() as u32 }; dp[n as usize] = Some(res); // println!("{} {}", n, res); res } } fn solve() { let s = stdin(); let s = s.lock(); let s = &mut BufReader::new(s); // for _ in 0..1 { let n: usize = read(s); let mut a: Vec<u32> = (0..n).map(|_| read(s)).collect(); a.sort(); let mut g = 0; let mut dp = vec![None; n + 1]; let mut i = 0; while i < n { let mut j = i; while j + 1 < n && a[j + 1] == a[j] + 1 { j += 1; } // [i,j] let k = j - i + 1; g ^= grundy(k as u32, &mut dp); i = j + 1; } println!("{}", if g == 0 { "Second" } else { "First" }); // } } fn main() { let stack_size = 104_857_600; // 100 MB let thd = std::thread::Builder::new().stack_size(stack_size); thd.spawn(solve).unwrap().join().unwrap(); }