python doesn't have any library for ordered map and ordered set. We can install sortedContainers module in our pc for that. Please include this module. It would be very helpful for all who code in python.
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
python doesn't have any library for ordered map and ordered set. We can install sortedContainers module in our pc for that. Please include this module. It would be very helpful for all who code in python.
Name |
---|
"Just use C++" virgin vs sortedContainers chad
vs Gods who know how to write their own Treap/RB Tree/2-3 Tree/AVL Tree/Scapegoat Tree/Skip List/Any BBST-like data structure
you can also use your own template of sortedlist .. etc
still, the sortedlist template runs in n^(1/3) which is more than the sortedcontainers's sortedlist which runs in nlogn
Just copy the sortedcontainers SortedList source code lol
can you use it directly though? If you could I would think pyrival would already directly copy it without rewriting the whole thing with a higher time complexity
PyRival has a shortened version here. However this version changes .add() to .insert(), .bisect_left() to .lower_bound(), and .bisect_right() to .upper_bound(). I use an older version that retains .add(), .bisect_left(), .upper_bound() and also has the Fenwick tree within the same class, which you may refer here.
Thanks it is better and short
thanks;) huikang
The docs are somewhat confusing in this regard. They say approximate nlogn but then the theoretical bounds are different:
https://grantjenks.com/docs/sortedcontainers/performance-scale.html
That is bullshit. Sortedcontainer's sortedlist runs in O(n^(1/3)) as they explain here.
It doesn't come with the default of any Python implementation, so maybe not.