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

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

In yesterday's div1+2 contest problem E (1804E) required an optimization for bitmask dp looking for cycles that has appeared waaaaaay before in cf, dating back to the beta days in this problem. It seems that it wasn't that well known, looking at the number of TLE submissions, so I'm posting this blog to remind people that there are old rounds/contests and they do have some good or educational problems.

One silly lesson that I learned from an old-ish problem is that writing some combinatorics problems in polynomial form sometimes might expose some observations that might not be obvious at first glance. Perhaps if you have some similar experience you could share it in this blog, as there would be at least one person interested in seeing it (me).

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

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

> ... there are old rounds/contests and they do have some good or educational problems

unlike modern problems

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

    You dont participate since 2018 dude. Go use your dial up internet to hate somewhere else

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

I have one cute problem that could be trivialize by writing the problem into polynomial form.

Problem: Given non-negative integer $$$N, M$$$, find the number of non-decreasing sequence $$$A$$$ with length $$$N$$$ s.t. $$$0 \le A_i \le M \text{ }\forall 1 \le i \le N$$$

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

This year's IOI had a dp problem which rewritten in polynomial form required multiplying out a lot of linear polynomials, take the derivative and evaluate at 1. We can use Leibniz's rule to see that we need to calculate the product of the linear coefficient of one factor and multiply it with all the other factors evaluated at one.

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

    This year's IOI?

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

      Obviously he means IOI 2022.

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

        Of course I know that, but it doesn't change the fact that it's wrong. Imagine someone reading the comment later this year.

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

          If you read ppavic's comment in December it will say "9 months ago", everyone will deduce that it's about IOI 2022, lol. Or maybe it's about IOI 2027 ?????!!1!1?

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

    Are you talking about IOI 2022 Fish? I didn't know that it has a solution with polynomials and derivative.

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

After read this post I started thinking about how to optimize this problem to $$$O(n^2 2^n)$$$, It's really a cool idea (I don't know if it's the same idea) that you can first find all cycles containing vertex 20, then find all cycles containing vertex 19 and not containing vertex 20 and so on.. $$$O(n^2*2^n + (n-1)^2*2^{n-1} + ... ) = O(n^2 2^n)$$$

Unfortunately I wrote 140 lines of code in 1804E but at least I got AC in first try.

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

n/1+n/2+n/3...+n/n = n*log2(n) I forget about it every time XD

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

    nope it's $$$n\times \ln(n)$$$ but not a big problem

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

      It's also not that. If we want to be precise then it's O(NlogN). Before someone replies this with something even more precise, I know that there's a known bound for the error.

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

Late to the party, but shameless self-plug

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

I've actually seen cycle finding bitmask dp relatively recently (only 1 year ago compared to 13 years ago) in this usaco problem: http://www.usaco.org/index.php?page=viewproblem2&cpid=1209

Its a pretty neat trick and I agree that there might be value in practicing older problems.