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) { 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 {} } }