Storing boolean array-like object of size 1e9 in Python3

Правка en1, от PiStroke, 2022-06-19 09:35:59

Recently, I came across this blog which explains bitwise operations in vector (c++).

Problem: You are given 10**7 integers in the range [0,10**9], find the number of distinct integers.

In python making a boolean list/array wouldn't help, an integer will occupy at least 24 bits and a bool will occupy 8 bits, the issue is it would lead to MLE, which isn't desirable!

Are there any python alternatives for vector?

I looked up numPy (even though it's not allowed in online Judge) but it doesn't seem to have one. Bitarray might be of some help, but I believe it's not allowed in Online Judge either.

Теги python3, bitarray, bool, memory limit

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский PiStroke 2022-06-19 09:39:16 12 Tiny change: 'for vector<bool>?\n\nI lo' -> 'for vector/<bool/>?\n\nI lo'
en1 Английский PiStroke 2022-06-19 09:35:59 720 Initial revision (published)