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

Автор ncduy0303, история, 4 года назад, По-английски

I created my own repository for CP purposes. I have tried to include as many commonly used algorithms and data structures as possible (some are taken from different sources).

Link: https://ncduy0303.github.io/Competitive-Programming/

Hope that somebody will find it useful and feel free to report any bugs :)

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

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Seems like quite a good starting point! Here are few suggestions. I won't write down what to add, because there are so many things to write in template and I don't know what you've intended to cover in your template. Hence these are only improvement suggestions. i.e, faster algorithm for a problem currently covered which are valid topics in CP, as far as I know.

  1. Maximum flow can be solved faster in Dinic's algorithm. I remember as $$$O(V^2 E)$$$ which is faster than Edmond-Karp. Unfortunately I do not recall a particular problem which is solvable by Dinic and not by E-K, but I am almost certain there are, since Dinic is actually faster than it looks in practice.

  2. I recommend studying $$$O(n^2 \log n)$$$ algorithm for 2D maximum sum subarray problem. I saw it twice, from ICPC Seoul Regional 2019 (I can't find this on CF Gym...) and Korean Olympiad. Here is a link to ICPC one, in Korean Online Judge. This can be done by segment tree + line sweeping technique.

  3. (I think you might know this) Precomputing factorials and using modulo inverse is usually cheaper for computing binomial coefficients

BTW, your codes look so much better than mine. Thanks for sharing :)

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +12 Проголосовать: не нравится

    About a problem that can be solved by dinic but not E-K, just try any bipartite matching problem with around 1e5 vertices for example this.

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

      Thanks! However I don't still get it in my mind...
      If I remember correctly, I've learned that (as I wrote) Dinic is $$$O(V^2E)$$$ but faster in practice. Your link seems to have V, E both about 1e5, which I wonder why it is solvable with Dinic. It should be way too big V E even with dinic... Is there something I'm missing??

      Thanks in advance.

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

    I don't know if there exists any algorithm better than O(n³) for a general maximum sum submatrix problem. The problem you linked has only O(n) non zero entries in the matrix, so its solvable with a better complexity.

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

      Ah. My mistake.. I read the wrong thing on his original code. Sorry for misinformation...:(