結果
問題 | No.2813 Cookie |
ユーザー | 37kt |
提出日時 | 2024-08-09 13:22:45 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,143 bytes |
コンパイル時間 | 12,576 ms |
コンパイル使用メモリ | 402,240 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-09 13:23:03 |
合計ジャッジ時間 | 15,250 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 1 ms
5,376 KB |
testcase_27 | AC | 1 ms
5,376 KB |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 1 ms
5,376 KB |
testcase_30 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
warning: function `dfs` is never used --> src/main.rs:13:4 | 13 | fn dfs(n: usize, c: usize, g: usize, st: &mut BTreeSet<usize>) { | ^^^ | = note: `#[warn(dead_code)]` on by default warning: function `f_reset` is never used --> src/main.rs:47:132 | 47 | ...< usize > > > = std :: cell :: RefCell :: new (vec ! [])) ; fn f_reset () { F . with (| cache | { let mut r = cache . borrow_mut () ; ... | ^^^^^^^ warning: function `f` is never used --> src/main.rs:47:228 | 47 | ... | { let mut r = cache . borrow_mut () ; r . clear () ; }) ; } fn f (n : usize) -> usize { if let Some (ret) = F . with (| cache | { l... | ^
ソースコード
pub use __cargo_equip::prelude::*; use std::collections::BTreeSet; #[allow(unused_imports)] use memoise::memoise; #[allow(unused_imports)] use proconio::{ input, marker::{Bytes, Chars, Usize1}, }; fn dfs(n: usize, c: usize, g: usize, st: &mut BTreeSet<usize>) { if n == 0 { st.insert(g); return; } if n < c { return; } let mut h = g; for i in (0..=n).step_by(c) { dfs(n - i, c + 1, h, st); h ^= f(c); } } /*#[memoise(n)] fn f(n: usize) -> usize { if n == 0 { 0 } else if n == 1 { 1 } else { let mut st = BTreeSet::new(); st.insert(0); for i in 1..=n { dfs(n - i, 2, i & 1, &mut st); } for i in 0.. { if !st.contains(&i) { return i; } } unreachable!(); } }*/thread_local ! (static F : std :: cell :: RefCell < Vec < Option < usize > > > = std :: cell :: RefCell :: new (vec ! [])) ; fn f_reset () { F . with (| cache | { let mut r = cache . borrow_mut () ; r . clear () ; }) ; } fn f (n : usize) -> usize { if let Some (ret) = F . with (| cache | { let mut bm = cache . borrow_mut () ; if bm . len () <= (n) as usize { bm . resize ((n) as usize + 1 , None) ; } bm [(n) as usize] . clone () }) { return ret ; } let ret : usize = (|| { if n == 0 { 0 } else if n == 1 { 1 } else { let mut st = BTreeSet :: new () ; st . insert (0) ; for i in 1 ..= n { dfs (n - i , 2 , i & 1 , & mut st) ; } for i in 0 .. { if ! st . contains (& i) { return i ; } } unreachable ! () ; } }) () ; F . with (| cache | { let mut bm = cache . borrow_mut () ; bm [(n) as usize] = Some (ret . clone ()) ; }) ; ret } fn main() { input! { t: usize, } for _ in 0..t { input! { n: usize, a: [usize; n], } let f = |x: usize| match x { 0 => 0, 1 | 2 => 1, x => (x + 1) / 2 * 2, }; let s = a.iter().map(|&x| f(x)).fold(0, |acc, x| acc ^ x); println!("{}", if s == 0 { "Bob" } else { "Alice" }); } } // The following code was expanded by `cargo-equip`. /// # Procedural macros /// /// - `memoise 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)` licensed under `BSD-3-Clause` #[cfg_attr(any(), rustfmt::skip)] #[allow(unused)] mod __cargo_equip { pub(crate) mod crates { pub mod memoise {pub use crate::__cargo_equip::macros::memoise::*;#[macro_export]macro_rules!__cargo_equip_macro_def_memoise_memoise{($(_:tt)*)=>(::std::compile_error!("`memoise` from `memoise 0.3.2` should have been expanded");)}#[macro_export]macro_rules!__cargo_equip_macro_def_memoise_memoise_map{($(_:tt)*)=>(::std::compile_error!("`memoise_map` from `memoise 0.3.2` should have been expanded");)}} } pub(crate) mod macros { pub mod memoise {pub use crate::{__cargo_equip_macro_def_memoise_memoise as memoise,__cargo_equip_macro_def_memoise_memoise_map as memoise_map};} } pub(crate) mod prelude {pub use crate::__cargo_equip::crates::*;} mod preludes { pub mod memoise {} } }