Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя 123gjweq2

Автор 123gjweq2, история, 5 часов назад, По-английски

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

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
5 часов назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

Yes, you can write your own implementation.

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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.

  • »
    »
    4 часа назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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?

    • »
      »
      »
      4 часа назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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).

»
4 часа назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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.