Блог пользователя reirugan

Автор reirugan, история, 13 месяцев назад, По-английски

Last weekend I finally hit CM, and today I reached a rating of over 2000, so in celebration, here's a list of some things I've heard of but don't know. I'm relatively new to CP—I started in August 2024—so there are a lot of techniques that most people probably consider standard that I'm not familiar with; feel free to comment below with more suggestions. (This definitely is not a copycat of a certain other famous blog, I swear this is a completely original idea.)

  • Lazy propagation in segment trees
  • Fenwick trees
  • Sparse table
  • Sqrt decomposition
  • Mo's algorithm, which cost me an ICPC solve
  • Small-to-large merging
  • Binary search trees, including treaps
  • Heavy-light decomposition
  • Binary lifting
  • I've never implemented most graph algorithms, including Kruskal's/Prim's, Bellman-Ford, Floyd-Warshall, etc
  • I don't think I've ever implemented BFS before, although I know the general idea
  • Actually I don't think I've ever implemented any $$$O(n\log{n})$$$ sorting algorithm before; I just use std::sort()
  • Flows (I don't even have the slightest idea of what this is)
  • Ternary search
  • Chinese Remainder Theorem (I have a vague sense of what it is, though)
  • Convex hull
  • Fast fourier transform
  • Pretty much any geometry
  • Any string algorithms (although I'm familiar with the general idea of some of them)
  • Anything about hashing
  • How to compute binomial coefficients of large numbers quickly (is this possible?)
  • Every single thing in this list

Just as a bonus, I don't think I've ever AC'd a problem during contest using either DSU or segment trees. As a second bonus, I also do not know how to install C++, use the command prompt, use Github, or write legible code.

Knowing techniques can be useful, but in general I think it's possible to hit CM (perhaps even Master) with only knowledge of basic programming (I/O, control statements, etc), what's provided in C++ standard library (vectors/arrays, sets/multisets, sort(), etc), DP, and some basic combinatorics.

  • Проголосовать: нравится
  • +138
  • Проголосовать: не нравится

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

orz reirugan congrats on CM

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +25 Проголосовать: не нравится

so, you know how to get a generating function?

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

afaik it is possible to compute binomial coefficients, from what i know the most efficient way is is to precalculate the factorials and use modular inverses which works in O(n) for the precomputation and O(log n) for each query. i might be wrong though

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how did you reach CM from August 2024? What type of experience did you have?

  • »
    »
    13 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +45 Проголосовать: не нравится

    i like olympiad math, probably helps

    • »
      »
      »
      13 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится +3 Проголосовать: не нравится

      like olympiad maths- also don't know Chinese remainder theorem. crt is quite easy just a glance over it will suffice ig. as for geometry if you want to work upon that there is an excellent course on couresera by some russian uni called computational geometry, solving geometry problems from aurthur engle would help in. apart from that there is a lot more in this list i still have to learn. so thanks for that hope you have a nice time learning geometry.

      ps. forgive my spelling errors i am severely dyslexic

      • »
        »
        »
        »
        13 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится +23 Проголосовать: не нравится

        brother you have 4 skipped contests

      • »
        »
        »
        »
        13 месяцев назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится 0 Проголосовать: не нравится

        I didn't say I was good at oly math lol, just that I like it :)

        I didn't take competition math seriously at all in high school, so I didn't make it very far in the US track. In university I started looking over oly problems casually for fun, and I also take the Putnam every year (which is the North American undergraduate math olympiad). I've done alright (I placed top 700) but nothing special. I'm pretty weak at N and G (luckily Putnam doesn't have G though); I'm decent at C and A.

        That being said, I still think it's fun. One does not have to be good at things to enjoy them.

        • »
          »
          »
          »
          »
          13 месяцев назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          top 700 in putnam is amazing, i hope i am good enough for simon marais next year, i meant no disrespect by my comment nor was it a judgement, it was poised more as a joke, and making my recommendations of some resources i have come across. I am sorry if i offended you in any manner.

          • »
            »
            »
            »
            »
            »
            13 месяцев назад, скрыть # ^ |
            Rev. 4  
            Проголосовать: нравится 0 Проголосовать: не нравится

            not offended, don't worry :)

            P.S. Lilypad said the same thing to me. After he read this blog, he DM'd me "bro there is actually no way you don't know what crt is". Honestly fair, most oly mathers probably do know CRT lmao, perhaps that's the most surprising thing on this list.

            I think some math theorems are derivable, though. I derived Legendre's while solving a problem without knowing it was a known formula (to be fair, it's pretty easy if you know how factorials and prime factorizations work), and I also used p-adic valuation on the Putnam without knowing it was a real thing. Some things are fairly straightforward.

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

I find it fascinating how you’re unfamiliar with many concepts that are considered fundamental in competitive programming from an Olympiad perspective: like Fenwick trees, sparse tables, sqrt decomposition, Mo’s algorithm, small-to-large, binary search trees, heavy-light decomposition, binary lifting, and ternary search.

This is a testament to how much math can help you on Codeforces. Congratulations on reaching CM!

»
13 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +13 Проголосовать: не нравится

As a new master I will say I agree with 96% of what you said.

Interestingly, at least in my memory, the majority of the other 4% comes from contests that are unrated for experts+(some div3 G problems)(Excluding 2500+ problems)

»
13 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +123 Проголосовать: не нравится

There is a big difference between "don't learn unnecessary things" and "not learning things you should know". If you said the above list when you are orange, then I think it is very much in the second class. For CM, I think it is midway between.

Besides start costing actual solves (where the technique is the only solution), you must also appreciapte how standard DS or techniques can allow you to skip observations, or allow you to look at some "apparently smart things" and they become useless. Efficient use of standard DS to simplify coding can make life so much easier.

I just don't want this blog to have a sentiment of "proud to be lazy", that's all.

Though in some sense, I hitted CM after doing aboslutely nothing — at that point I would know many of things you said but will never be able to implement it. But surely, you could reach CM without any of these, but you probably won't want to stop at CM right

  • »
    »
    13 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    This is true. That being said, I think at least in Div2 CF rounds specifically, technique is perhaps slightly less prioritized than in other contests (and since I don't really do any CP other than Div2 CF, technique perhaps isn't my main priority). As far as I can remember, I can't think of a specific instance where I feel like anything on the above list cost me a CF solve — usually if I see something I'm not familiar with in the editorial of a problem I struggled with during a contest, I'll learn the technique on the spot, but this is quite rare. Now that I can compete in Div1, perhaps this will be different going forward. In any case, thanks for your advice!

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

For CNOIers, this is unimaginable.

  • »
    »
    7 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Yes, although I roughly knew what to expect before clicking, I was still shocked by what I saw.

    But upon reflection, I realized that I haven't actually used those algorithms and data structures I'm familiar with on Codeforces (except for using a segment tree once), even though they are quite useful in the CNOI series of competitions.

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a person who has participated in this platform in 4 years, that is most of the time correct. Usually, it's us overthinking the pattern to problems rated CM below...

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

congrats for 2000+

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

"Pretty much any geometry"

I felt that

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

The emphasis on so-called algorithms has led many learners down a detour. I don't think those algorithms aren't important.

I think if somebody always practice on Codeforces and can't keep on purple(just like me), learning too many algorithms can be misleading because they can't master using these algorithms.

I found a very strange phenomenon that some of the kids who are learning programming are now learning digital dynamic programming, but many of them can't even write the correct 01 backpack and full backpack code.

I believe that the learning of programming is a process of long-term understanding and experience, rather than the accumulation of these algorithms.

Although I stayed at blue for a long time, however, when I checked the solution after the competition, I always found that the reason why I did not do the next question was not that I did not know the knowledge point, but that I did not master it.

»
13 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
  • How to compute binomial coefficients of large numbers quickly (is this possible?)

You can do it under a prime modulo with mod inverse and precomping factorials

Also surprised at some of the stuff on this list if you're doing ICPC. I feel like there's frequently problems in the style of "easy solve if you know x algorithm" at NA regionals. Like there was one problem on SER this year that was gatekept by tree diameter knowledge and another that was gatekept by string algorithm knowledge. I can understand not learning a lot of these things if you're just doing div2 cf rounds but for ICPC it's definitely worth learning a lot of this stuff just so you can solve it if a problem using it shows up.

  • »
    »
    13 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Yep, dnialh mentioned the binomial coefficients one :)

    And yes, you're probably right. I've only done ICPC once (GNYR in 2024) and we didn't do particularly well (we did alright, but not near contention for NAC) even though our team was fairly decent by CF level. Maybe we should learn more algorithms if we want to have a shot at NAC lol. We'll see, though. If my teammates tell me that they really care about pushing for NAC later this year, then I'll definitely study so as to not hold them back, of course. Right now, I'd say I value CF more, though.

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As an expert, I am on the same page. I know sparse tables, tho and know the basic idea behind lazy segment trees.

And the only problem I have got AC (during contest) using a segtree or dsu was this whose intended solution is priority queue.

And I have one AC in atcoder where I used segtree and intended was fenwick or lazy segment tree

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

CM too and I will go down ur list.

  • Lazy propogation : heard of it never implemented it except for one time in ICPC when I copied it from KACTL.
  • Fenwick trees : heard of it never even found a use for it.
  • Sparse Table : ?
  • Sqrt/Mo : heard of it know of uses, never implemented it.
  • Small to Large : only implemented it in the context fo DSU (which I copied from benQ initially).
  • True BSTs : never implemented in contest (but had to for one of my classes).
  • HLD : heard of it, never implemented it.
  • Binary lifted : literally implemented it first time three days ago for a competiiton.
  • Kruskall's/BF/Fw : Vaguely heard abt it, never implemented it (outside of said BST class).
  • BFS : IDK what to tell you buddy (Djikstra's is basically BFS with a PQueue so if you implemeted Djikstra's you implemented BFS).
  • sort : honestly would be surprised if anyone wrote a custom sort for a contest, but have implented it for the same class described elsewhere in my reply.
  • flows : went right over my head when I read abt it.
  • ternary search : https://mirror.codeforces.com/contest/1985/problem/H2 (this is the easiest problem by far where ternary search is necessary). Though have not used it for finding max/min which is its intended use ig.
  • CRT : Only implemented it in discrete math and math comps (never programming comps).
  • Convex Hull : Not even close.
  • FFT : Only understood it after one of my classes spent 5 lectures on it, still no real idea on implementation. -Geo: Yeah same
  • String algos : Only implement KMT in rare cases (though have implemented more for classes).
  • Hashes : Same as string algos.
  • Binomial coefficients : Hash factorials and then use modular division to calculate binomials in O(1) time.
  • Um Nik: Lol I dont even understand half the shit being discussed there.

The class I keep mentioning: Georgia Tech's CS 1332

Over all yeah I agree with this, but you do need to learn some more DSA to improve. On the bright side, you are more than good enough for >99% of technical interviews already so this is a CP rather that general idea.

»
13 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I know most of things you say,but i am still CM lol

»
13 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Also, to compute every coefficient of the form $$$\binom{m}{i}$$$ where $$$m$$$ is a fixed large number and $$$1\le i\le n$$$ where $$$n=5\cdot 10^5$$$ or something, you can just use $$$\binom{m}{i}\cdot \frac{m-i}{i+1}=\binom{m}{i+1}$$$. You can make it faster by precomputing inverses from $$$2$$$ to $$$n+1$$$ in $$$O(n)$$$, see https://cp-algorithms.com/algebra/module-inverse.html#finding-the-modular-inverse-for-array-of-numbers-modulo-m

Problem where I used this in-contest: https://mirror.codeforces.com/contest/1929/problem/F

»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Now that you're a master, have you crossed out any item of the list? :-)

  • »
    »
    7 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +9 Проголосовать: не нравится

    Several of them, I learned during contests because I knew the general idea of what it did, so I recognized it'd apply and read an article when I needed it lmao.

    • Lazy segtree, learned during 2150C - Limited Edition Shop
    • Fenwick trees, learned from CP-Algorithms on my own, used in contest several times
    • Sparse tables, I read the CP-Algorithms page at some point, don't fully remember the implementation but I know what it does
    • Small-to-large merging (well it's intuitive, you do small to large), learned during 2127E - Ancient Tree
    • I have implemented a BFS, while writing a brute forcer for some discarded problem I wrote
    • Flows, I read the CP-Algorithms page on Ford Fulkerson but don't fully remember it
    • Chinese Remainder Theorem (I already mostly knew the intuition, but after I posted this blog Lilypad told me it was ridiculous I didn't know the formal statement and explained it to me)
    • Computing binomial coefficients in $$$O(1)$$$ with $$$O(\max n)$$$ precomputing, thanks to a comment by dnialh in this blog
    • From the Um_nik list, I learned mergesort tree from macaquedev for some discarded problem he wrote

    I think that's it.

»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

I almost know 12 of the things mentioned, and I'm still a specialist. Especially these days, I feel like I'm suffering from brain rot, but I'm sure the breaking point is on its way. I'm also hoping to be a candidate master by the end of the year.