結果
| 問題 |
No.2813 Cookie
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-09 13:24:44 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,143 bytes |
| コンパイル時間 | 12,506 ms |
| コンパイル使用メモリ | 402,520 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-09 13:25:07 |
| 合計ジャッジ時間 | 14,397 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 25 |
コンパイルメッセージ
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 {}
}
}