Bitset
A bitset is an array whose each value is either 0 or 1.
The following code creates a bitset that contains 10 elements:
bitset<10> s;
s[1] = 1;
s[3] = 1;
s[4] = 1;
s[7] = 1;
cout << s[4] << "\n"; // 1
cout << s[5] << "\n"; // 0
// To reset to 0
s.reset();
Applications
- 2022-05-29: Wow! Just used Bitset for the first time solving this Codeforces B. Stone Age Problem, which was too slow with a regular Set
- I’m pretty sure I meant Vector (C++) here