Since there were more overseas participants than expected, I set up a discussion blog just in case.
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | dXqwq | 3436 |
| 8 | Radewoosh | 3415 |
| 9 | Otomachi_Una | 3413 |
| 10 | Um_nik | 3376 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | adamant | 152 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 144 |
| 5 | errorgorn | 141 |
| 6 | cry | 139 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 9 | TheScrasse | 134 |
Since there were more overseas participants than expected, I set up a discussion blog just in case.
| Name |
|---|



Auto comment: topic has been updated by Nyaan (previous revision, new revision, compare).
Here's problem K
Thank you for this contest, I enjoyed the problems a lot!
I am not very much familiar with atcoder. how to see the eps from 1 to 23? if there exist any?
I am guessing the 24 just stands for the number of problems in the contest
Is there anything wrong with my ntt? I've used this one for quite a while but I've been getting TLE'd hard on some of these. For example, my solution for C: https://pastebin.com/P0dz2S1x
I think these problems were designed under an assumption that you have some optimized version of ntt, for example the one from Atcoder library. In particular, using Montgomery multiplication is much faster than taking long longs modulo mod
makes sense, thanks
I am not able to understand editorial of problem L, can somebody help me.
I solved it in slightly different way:
So, we can use inclusion — exclusion on length 2 cycles (Lets call them as pair).
Submission
By this way, we can compute our answer in $$$O(N)$$$ I dont see a need to use FPS here, or neither I am not able to understand how to use FPS in this problem.
wait there is an editorial? i cant find any in the contest's editorial section
Japanese editorial exist.
Sometimes you compute a power series by DP. The answer can be described as a coefficient of a nice function.
For what I understand, the editorial tries to exemplify the exponential formula, which is basically finding relations of the kind $$$ H=e^D $$$ for $$$H$$$, $$$D$$$ EGF's. The idea is more or less:
I have some elements represented by $$$D$$$. $$$H$$$ can be formed by taking a single element of $$$D$$$, or taking two elements of $$$D$$$ and renaming, taking three elements of $$$D$$$ and renaming ...etc.
Taking a single element is just adding $$$D$$$, taking two and renaming is doing $$$\sum_n(\sum_{n=i+j} \frac{n!}{i!j!}d_id_j)\frac{x^n}{2}=\frac{D^2}{2!}$$$ (the $$$/2$$$ I interpret it as preventing the overcounting for cases $$$i=a,j=b$$$ and $$$i=b,j=a$$$), in general taking $$$k$$$ elements from $$$D$$$ and renaming is
Then $$$H=1+D+\frac{D^2}{2!}+\frac{D^3}{3!}+\dots =e^D$$$.
For the problem L, one can think $$$H$$$ as the amount of permutations and $$$D$$$ as the cycles. The EGF for cycles is $$$\sum_{n\geq 1}(n-1)!\frac{x^n}{n!}$$$, but as we don't want any cycle of length $$$1$$$ or $$$2$$$ we just make $$$D=\sum_{n\geq 3}(n-1)!\frac{x^n}{n!}$$$
Hope this helps. I read about this in generatingfunctinology (the whole second chapter is basically ideas related to the exponential formula)
thanks. i will read more about these in generative functionology.
I didnt understand the overcounting scenario, (the /2 I interpret it as preventing the overcounting for cases i=a,j=b and i=b,j=a), but what happens if i = j.
What we are actually counting is the number of ways to also label the nodes of the cycles, with labels from $$$1$$$ to $$$n$$$. So when the cycle lengths are the same you are still double counting, so even then the $$$/2$$$ is justified. The /k! basically makes sure that cycle $$$1$$$ gets the label $$$1$$$, cycle $$$2$$$ gets the next smallest available label, and so on.
thanks for the explanation, got it now
You need to count permutations s.t. no permutation has a cycle of size $$$1$$$ or $$$2$$$, which are the only two ways you can get $$$p_{p_i} = i$$$. From exponential formula, EGF for a set of structures having EGF $$$A(x)$$$ is $$$\exp A(x)$$$.
The EGF of cycles is $$$\log\frac{1}{1-x} = \sum\limits_{k=1}^\infty (k-1)!\frac{x^k}{k!}$$$, and you need to make a set of those with $$$k \gt 2$$$, so the answer is
Here, we subtracted $$$x$$$ and $$$\frac{x^2}{2}$$$ to get rid of the "bad" cycles.
A possible faster way here, corresponding to your linear solution is is to represent it as
since $$$\frac{e^{-x}}{1-x}$$$ is, indeed, the generating function for derangements.