1 unstable release

0.1.0 Jun 27, 2019

#2686 in Data structures

Download history 156/week @ 2024-09-30 105/week @ 2024-10-07 95/week @ 2024-10-14 110/week @ 2024-10-21 125/week @ 2024-10-28 128/week @ 2024-11-04 46/week @ 2024-11-11 95/week @ 2024-11-18 147/week @ 2024-11-25 145/week @ 2024-12-02 293/week @ 2024-12-09 290/week @ 2024-12-16 322/week @ 2024-12-23 389/week @ 2024-12-30 435/week @ 2025-01-06 480/week @ 2025-01-13

1,630 downloads per month
Used in 3 crates

MIT license

13KB
378 lines

bitset-fixed

Bitset for DP.

Example

Example for AGC20-C

use bitset_fixed::BitSet;
use rand::prelude::*;

fn main() {
    let mut rng = StdRng::seed_from_u64(114514);

    let n: Vec<usize> = (0..25).map(|_| rng.next_u32() as usize % 2000).collect();
    let sum = n.iter().sum::<usize>();

    let mut bitset = BitSet::new(sum + 1);
    bitset.set(0, true);

    for &x in &n {
        bitset |= &(&bitset << x);
    }

    let ans = ((sum + 1) / 2..).find(|&i| bitset[i]).unwrap();

    println!("N = {:?}\nAnswer = {}", n, ans);
}

No runtime deps