結果
問題 | No.715 集合と二人ゲーム |
ユーザー | fukafukatani |
提出日時 | 2019-02-09 11:27:41 |
言語 | Rust (1.77.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,610 bytes |
コンパイル時間 | 2,027 ms |
コンパイル使用メモリ | 162,776 KB |
実行使用メモリ | 7,888 KB |
最終ジャッジ日時 | 2023-09-14 11:05:08 |
合計ジャッジ時間 | 13,071 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 4 ms
4,376 KB |
testcase_03 | AC | 8 ms
4,376 KB |
testcase_04 | AC | 13 ms
4,376 KB |
testcase_05 | AC | 17 ms
4,380 KB |
testcase_06 | AC | 21 ms
4,380 KB |
testcase_07 | AC | 32 ms
4,376 KB |
testcase_08 | AC | 42 ms
4,376 KB |
testcase_09 | AC | 53 ms
4,380 KB |
testcase_10 | AC | 56 ms
4,384 KB |
testcase_11 | AC | 71 ms
4,380 KB |
testcase_12 | AC | 94 ms
4,380 KB |
testcase_13 | AC | 107 ms
4,376 KB |
testcase_14 | AC | 122 ms
4,376 KB |
testcase_15 | AC | 146 ms
4,376 KB |
testcase_16 | AC | 153 ms
4,380 KB |
testcase_17 | AC | 133 ms
4,376 KB |
testcase_18 | AC | 199 ms
4,380 KB |
testcase_19 | AC | 228 ms
4,380 KB |
testcase_20 | AC | 205 ms
4,380 KB |
testcase_21 | AC | 262 ms
4,376 KB |
testcase_22 | AC | 308 ms
4,376 KB |
testcase_23 | AC | 324 ms
4,376 KB |
testcase_24 | AC | 370 ms
4,500 KB |
testcase_25 | AC | 367 ms
4,376 KB |
testcase_26 | AC | 351 ms
4,376 KB |
testcase_27 | AC | 422 ms
4,380 KB |
testcase_28 | AC | 498 ms
4,376 KB |
testcase_29 | AC | 515 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 | -- | - |
ソースコード
#[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 grundy(m: usize, mem: &mut Vec<i32>) -> i32 { if mem[m] != -1 { return mem[m]; } let mut s = HashSet::new(); if m > 1 { s.insert(mem[m - 2]); } else { s.insert(mem[m - 1]); } 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; res - 1 } 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; // println!("{:?}", mountains); // println!("{:?}", mem); for m in 0..max_elem + 1 { grundy(m, &mut mem); } let result = mountains.iter().fold(0, |s, &x| s ^ mem[x]); if result == 0 { println!("Second"); } else { println!("First"); } }