can anyone help me explain this technique, is this technique used frequently in famous contests such as icpc,ioi...? sorry for my poor english
# | 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 |
can anyone help me explain this technique, is this technique used frequently in famous contests such as icpc,ioi...? sorry for my poor english
Name |
---|
Just take the advice from Um_nik: "Stop learning useless algorithms, go and solve some problems, learn how to use binary search".
There's no need to take some algos down. DSU roll back offline deletion is also a common and useful algo with widely use. It's easy, too. Just use a
stack
to record the operations andpop
while you need to roll back, which is much shorter than sustainable DSU.I think Um_nik's words are not right at all. On one hand, for example, in China, it's necessary to use some "useless algorithms" like Li-Chao Segment Tree, Segment Tree Beats and $$$k$$$-th shortest path expertly for the OIers who's just a junior high school with about 14 years old. MST in $$$O(E\log V)$$$ is one of the key tools for 12 year-old kids to get more points in the CSP Coding ability recognization. On the other hand, Codeforces is not the only OJ all around the world, although it has the most valuable problems. Many CPers spend their time on other OJ, maybe AtCoder for Japanese, Luogu for Chinese, or others. The color of the name on CF is not the only evidence to judge a CPer's ability.
Uselessness is not the excuse of laziness. Keeping learning is the most fun thing in the life.
My answer was mostly to this part of the question: "is this technique used frequently in famous contests such as icpc,ioi."
I believe there's very limited usefulness to learn advanced algorithms while more simple algorithms are not mastered.
"The color of the name on CF is not the only evidence to judge a CPer's ability." — I strongly disagree with this claim. It might be true if the user has too few contests but if one participated in, let's say, 10 contests — then we can reliably judge his/her ability.
to enable rollbacks in any data structure, we can simply save every change in
vector<pair<int&, int>>
, where first element in pair is link to changed memory, and second — value before change.When we need to undo last change, justchanges.back().first = changes.back().second;changes.pop_back();
remember, that in dsu you change multiply values in one query, so we need to undo a couple of changes to make rollback.