use std::collections::*; fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).unwrap(); ret } #[derive(Debug)] struct Stat<'a> { a: &'a [u32], unique: BTreeSet, // index freq: HashMap, } fn facil(a: &[u32]) -> Stat<'_> { let mut freq = HashMap::new(); for &f in a { *freq.entry(f).or_insert(0) += 1; } let stat = Stat { a: &a, unique: { let mut x = BTreeSet::new(); for i in 0..a.len() { if freq[&a[i]] == 1 { x.insert(i); } } x }, freq, }; stat } fn rec(s: Stat) -> i32 { let n = s.a.len(); let mut seen = 0; let mut ans = 0; for &idx in &s.unique { // TODO: O(n^2) let t = facil(&s.a[seen..idx]); ans += rec(t) + 1; seen = idx + 1; } if seen > 0 && seen < n { let t = facil(&s.a[seen..]); ans += rec(t); } // eprintln!("stat = {s:?}, ans = {ans}"); ans } // https://yukicoder.me/problems/no/3258 (3.5) fn main() { getline(); let f = getline().trim().split_whitespace() .map(|x| x.parse::().unwrap()) .collect::>(); let n = f.len(); let mut freq = HashMap::new(); for &f in &f { *freq.entry(f).or_insert(0) += 1; } let stat = Stat { a: &f, unique: { let mut x = BTreeSet::new(); for i in 0..n { if freq[&f[i]] == 1 { x.insert(i); } } x }, freq, }; println!("{}", if rec(stat) % 2 == 1 { "Alice" } else { "Bob" }); }