Please read the new rule regarding the restriction on the use of AI tools. ×

123gjweq2's blog

By 123gjweq2, history, 3 hours ago, In English

It looks like Rust doesn't have bitset in its std. Is there any alternative?

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
2 hours ago, # |
  Vote: I like it +9 Vote: I do not like it

Yes, you can write your own implementation.

»
2 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Egor has a contest library which includes bitset. https://github.com/EgorKulikov/rust_algo/blob/master/algo_lib/src/collections/bit_set.rs

At a glance it's not exactly the same (e.g. size is set at runtime) but may be good for your purposes.

  • »
    »
    2 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The rust king himself. Thanks broski. This might be a dumb question, but can I just copy-paste this into my code when I need to?

    • »
      »
      »
      109 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Codeforces and most other platforms allow you to copy code if it's public before the contest starts.

      With this particular library, it can be tricky because files often import other files in the library. The author uses an automated tool to splice together a file for submission. So it would probably be best for you to prepare a working version beforehand (or learn to use the library+tool).

»
103 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

I thought about bitset too, but in 3 months of solving ~2000-2400 problems, I haven't found a problem that you can't solve without it. The same with multiset.