use proconio::input; fn main() { input! { n: usize, _f: usize, abc: [[u32; n]; 3], } let abc = (0..n) .map(|i| [abc[0][i], abc[1][i], abc[2][i]]) .collect::<Vec<_>>(); let mut dp = vec![0u64; n + 1]; dp[0] = 1; let ans = abc .iter() .map(|x| { let mut swp = vec![0; n + 1]; for &x in x { for i in 0..=n { if i == 0 { swp[i] |= dp[i].wrapping_shl(x); } else { swp[i] |= dp[i].wrapping_shl(x) | dp[i - 1].wrapping_shr(63 - x); } } } dp = swp; println!("{:?}", dp); dp.iter().map(|dp| dp.count_ones()).sum::<u32>() }) .collect::<Vec<_>>(); println!( "{}", ans.iter() .map(std::string::ToString::to_string) .collect::<Vec<_>>() .join("\n") ); }