I don't know if this trick was introduced or named earlier. But I found it interesting and decided to write a blog about it. The trick is simple and I wrote the blog simple too. Hope you don't get confused.
Please ignore the Chinese interface.
# | User | Rating |
---|---|---|
1 | tourist | 3947 |
2 | jiangly | 3734 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3612 |
7 | ecnerwala | 3581 |
8 | Geothermal | 3569 |
8 | cnnfls_csy | 3569 |
10 | ksun48 | 3479 |
# | User | Contrib. |
---|---|---|
1 | awoo | 164 |
2 | maomao90 | 160 |
3 | nor | 156 |
3 | adamant | 156 |
5 | atcoder_official | 155 |
5 | -is-this-fft- | 155 |
7 | maroonrk | 153 |
7 | cry | 153 |
9 | SecondThread | 147 |
10 | Petr | 146 |
I don't know if this trick was introduced or named earlier. But I found it interesting and decided to write a blog about it. The trick is simple and I wrote the blog simple too. Hope you don't get confused.
Please ignore the Chinese interface.
Name |
---|
Using
set
seems overcomplicated because you can solve the problem mentioned in the blog without set at all just keeping current minimum and delta.+1.
The author should probably specify that a set could be used if adding a 4th operation like "check membership" (i.e. checking for $$$x$$$ corrresponds to searching the set for $$$x-\delta$$$)
Yes, that would have sense with such operation.
This trick indeed has a name, it's offset. It allows adding something to all elements of a set.
I dont understand how to execute operation 1, how is the delta added to all of the elements in the set?
[1, 2, 3] + 2 = [3, 4, 5]
Venice Technique
Might be irrelevant but, Here's the same question but with Xor as an operation: For the Curious Ones!
Wow, the trick is amazing trick. Something new for me to learn today.
This trick using
set
will be more useful when there is one more query to be performed:delete element X
. Just remove element (X − δ) from theset
ortreemap
(in Java), and there you go.