nns2009's blog

By nns2009, history, 21 month(s) ago, In English

(since I don’t have any following, this post will probably only get a few views, so in case you find it months/years later — yes, still relevant)

I am looking for some cool algorithms or data-structures, which are ingenious, clever and interesting, but also not prohibitively complicated, so it’s possible to re-discover them while solving some specific task.

My current knowledge for context

Re-invented before:

(stuff I came up with before I ever read or been taught about it)

  • Polynomial string hashes
  • Convex-Hull
  • Persistent data structures like trees (by familiarity with functional programming, immutability and such)
  • Graph min-span tree

Know-well:

  • Various graph algorithms
  • Various trees
  • RMQ
  • Prefix function, Aho-Corasick
  • Dynamic programming
  • DSU
  • Parsing by recursion

Remember in general details:

  • Suffix array

Coded previously, but never put effort to understand deeply and forgot:

  • Graph min/max flow
  • Suffix automaton
  • Some limited RMQ-like structure, which can only do a subset of operations, but has a lower constant and lower memory usage (don’t remember the name)

This is not an exhaustive set of what I know, but hopefully it gives you a general idea to suggest stuff, which I likely don’t know and will find interesting.

Ideally looking for:

  • CodeForces problem links
  • a name of the algorithm/data-structure needed to solve it (which I’ll try not to use/Google before solving myself)
  • Estimated difficulty to re-invent the algorithm and solve the corresponding problem(s)
  • Vote: I like it
  • +32
  • Vote: I do not like it

| Write comment?
»
21 month(s) ago, hide # |
← Rev. 2  
Vote: I like it +10 Vote: I do not like it

https://codeforces.me/problemset/problem/1949/B

Try to solve this in a time complexity that is not $$$O(n^2)$$$ or beyond. With this, you would reinvent:

Spoiler

Pardon me if I failed to meet your constraints due to my inexperience.

  • »
    »
    21 month(s) ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    Thanks for the suggestion!

    Wouldn't a simple min(sort(aa) — sort(bb)) work? Ha-ha-ha. That would be too easy, and they'd certainly make n>=200 000 in such a case.

    I'll think

»
21 month(s) ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

Not codeforces, but I like this problem a lot. It is in romanian but translation should be relatively simple. Try to do it in $$$O(N)$$$.

Problem

  • »
    »
    21 month(s) ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    but translation should be relatively simple

    Then translate it, what's the problem?

    • »
      »
      »
      21 month(s) ago, hide # ^ |
       
      Vote: I like it +1 Vote: I do not like it

      The problem gives you a tree. A node is either a know-all that can answer queries or a know-nothing and has to ask one of its ancestors for the answer to the query. Each know-nothing might have a different ancestor they need to ask (for each node there is a $$$k$$$ that specifies that you should ask the $$$k$$$-th ancestor).

      The task is to find for each node how many jumps a query makes (starting from that node) until it is answered.

      The actual interesting part
      • »
        »
        »
        »
        21 month(s) ago, hide # ^ |
         
        Vote: I like it -11 Vote: I do not like it

        Micro macro tree.

        • »
          »
          »
          »
          »
          21 month(s) ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          ?

          • »
            »
            »
            »
            »
            »
            21 month(s) ago, hide # ^ |
             
            Vote: I like it 0 Vote: I do not like it

            That's the solution to the 'The actual interesting part'.

            • »
              »
              »
              »
              »
              »
              »
              21 month(s) ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it

              I don't know what a micro macro tree is (although, I would not mind an explanation/resource).

              The intended solution is
»
21 month(s) ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

I suggest you to re-invent factorization algorithm which works in $$$O(poly(\log(n)))$$$ time where $$$n$$$ is the number to factorize.

»
21 month(s) ago, hide # |
 
Vote: I like it +12 Vote: I do not like it

Such a flex

»
21 month(s) ago, hide # |
← Rev. 2  
Vote: I like it +3 Vote: I do not like it
»
21 month(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

You can try 321C.

Solving this problem I reinvented...

You can also try CSES, Substring Reversals. On this problem I did not reinvent anything but I had a lot of fun thinking and learning / searching for stuff on the internet.

I learned...