Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Don't practice segment tree if you are below purple.

Revision en9, by TheScrasse, 2023-01-25 13:29:42

tl;dr

Please, don't practice segment tree if you are below purple.

UPD: ok, you can learn basic segment tree (Fenwick tree may be enough) if you want to overkill some problems. Just don't try to solve hard segment tree problems like this and this if you are cyan, because there are better ways to practice and learn something.

UPD: if you take part to OI, segment tree can be very useful (especially at regional level). Unlike on Codeforces, there may be easy-ish but not trivial segment tree problems (let's say with a rating around 2200). So, if you want to practice segment tree for some reason (e.g., you love segment trees, or you are practicing for OI), start with OI problems.

Why?

If you want to solve non-trivial segment tree problems, you should

  1. actually understand how segment tree works (including time complexity);
  2. have decent implementation skills;
  3. be able to convert the given problem into a segment tree problem.

If you are able to learn all these things, you already have purple skills. Conversely, if you are not purple, most probably you won't manage to actually learn segment tree.

Examples

  • Blog 1: the author asks how to solve a problem. Someone replies, linking a comment about another problem whose solution is almost identical to the original problem. The comment contains a detailed explanation of the solution and an AC code.
    The author of the blog replies that he wants an AC code of his problem because he can't implement the solution. It turns out it's because the provided AC code uses a segment tree as a struct.
  • Blog 2: the author is "confused" about the time and space complexity of his solution using a segment tree. It turns out his solution is worse than the naive solution.

Comments

  • Blog 1: if you understand the explanation of the solution, and you say you know segment tree, you should have no problems implementing the solution from scratch (point 2 above). If not, it means that you don't understand the solution, so the problem is too hard for you (3). Then, why would you need to solve it? Also, copy-pasting others' code without understanding it does not count as solving the problem. Then, why are you asking for the code?
  • Blog 2: I guess someone told you that the problem is solved "using segment tree" and you tried to implement a solution without even calculating the complexity (1). Please note that there may be multiple ways, both correct and wrong, to use segment tree in a problem (similarly, in other problems there may be multiple greedy solutions, both correct and wrong). So, if you are using segment tree, it doesn't mean that the code is "magically" efficient. Finding an actually correct solution can be hard (3).

Conclusion

It's fine not to be good at points 1, 2, 3 above if you are blue or below. There are other (more important?) things to learn at that level.

Side note: when I first became yellow, I had no clue about how to solve the linked problems. Now I can solve them, but I'm still yellow.

Tags segment tree, beginner, binary search

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en12 English TheScrasse 2023-01-25 16:06:11 226 Tiny change: 'an / blue.\n\n- If y' -> 'an / blue.<br>\n\n- If y'
en11 English TheScrasse 2023-01-25 13:52:54 9 Tiny change: 'blems.\n\nUPD: \n\nWhy?\n' -> 'blems.\n\nWhy?\n'
en10 English TheScrasse 2023-01-25 13:52:44 192
en9 English TheScrasse 2023-01-25 13:29:42 360
en8 English TheScrasse 2023-01-25 13:11:06 351
en7 English TheScrasse 2023-01-25 12:42:38 0 (published)
en6 English TheScrasse 2023-01-25 12:42:05 29 Tiny change: 'Please, do' -> 'tl;dr\n------------------\n\nPlease, do'
en5 English TheScrasse 2023-01-25 12:41:14 151
en4 English TheScrasse 2023-01-25 12:39:28 34
en3 English TheScrasse 2023-01-25 12:38:33 285
en2 English TheScrasse 2023-01-25 12:33:40 1315 Tiny change: ' a struct.\n\n- [Blo' -> ' a struct.<br>\n\n- [Blo'
en1 English TheScrasse 2023-01-25 12:11:24 1016 Initial revision (saved to drafts)