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 | 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 |
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.