The legend nssprogrammer has returned to Codeforces... to cheat with AI !?!

| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | Radewoosh | 3415 |
| 8 | Um_nik | 3376 |
| 9 | maroonrk | 3361 |
| 10 | XVIII | 3345 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 145 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 135 |
| 7 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 132 |
The legend nssprogrammer has returned to Codeforces... to cheat with AI !?!

In realms of numbers cold and starkly bright,
Where binary fields in darkened whispers hum,
There lies a dance in digital delight,
A symphony of ones and zeros come.
Fair Bitset, thy ethereal form doth weave,
Thy silent matrix spans eternity,
Within each place, a secret world conceive,
A code, a charm—pure possibility.
O'er silicon meadows where electrons fleet,
Thy silent banners rise, then fade away,
In thy precision, order is complete,
Yet mysteries within thee softly lay.
Each bit, a star within an endless dark,
Together luminesce, in ordered might,
No poet's quill or artist’s fragile arc
Can match the beauty of thy simplest sight.
O fleeting glimpse into the unknown vast,
Thy presence, such an empty canvas fill,
For in the heart of man and machine cast,
An ode to thee shall ever shimmer still.
In thee, the cosmos shrinks and magnifies,
Both infinite and minuscule align,
While verdant numbers like green ivy rise,
Entwining our most ephemeral sign.
O Bitset, dear ethereal and vast,
Thy data sings, transcending winds of time,
A haunting echo of the Future’s past,
Each twinkling digit true and so sublime.
Through thee, we trace the arcane paths untold,
Where thought and structure elegantly blend,
In binary, thine essence bright and bold,
Crafting the dream no end could e'er suspend.
UPD1: The bug has been fixed. I'll update the blog again when the fix is on Codeforces.
UPD: Unfortunately, left / right shift is bugged and doesn't clear bits properly. It should be fine for other operations, but use it at your own risk.
Hello sirs, you might know that Boost has a dynamically sized bitset class, but did you know that GCC also has one? Turns out it's included in the tr2 folder. You can simply include the <tr2/dynamic_bitset> header, and use it as std::tr2::dynamic_bitset. Yes, it works on Codeforces.
Here's a code example to count triangles in a graph (abc258_g):
#include <bits/stdc++.h> I wonder if it's possible to get GCC to fix it...
using namespace std;
#include <tr2/dynamic_bitset>
using namespace tr2;
signed main() {
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
int n; cin >> n;
vector<dynamic_bitset<>> adj(n);
for(int i = 0; i < n; i++){
adj[i].resize(n);
for(int j = 0; j < n; j++){
char c; cin >> c;
adj[i][j] = c-'0';
}
}
int64_t ans = 0;
for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++) if(adj[i][j]){
ans += (adj[i]&adj[j]).count();
}
cout << ans/3 << "\n";
}
In some problems, we might not be able to use a constant sized bitset. For example, on 1856E2 - PermuTree (hard version). Here's a submission where we replaced neal's custom_bitset template with using custom_bitset = tr2::dynamic_bitset<>;, and got accepted with little performance difference (260853192, original 217308610).
The implementation of the bitset seems identical to a version of Boost's dynamic bitset, so you can read the docs here. You can view the source here.
Comparing to std::bitset, here are some notable things I saw:
Of course, it also has all the normal std::bitset functionality. However, I'm not sure how fast this is compared to std::bitset; you can let me know in the comments. Interestingly, it seems to be using 64 bit integers on Codeforces.
If you enjoyed this blog, please make sure to like and subscribe for more bitset content.
Thanks rewhile for helping with the blog.
| Name |
|---|


