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 | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
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.