SEUNGHWAN KIM

LGCPC 2025

TAGSNEWSCOMPETITION

I participated in the LGCPC 2025 finals, placing in the 20s. As awards were only given to the top three contestants, I felt rather little pressure, though this naturally led to a lack of motivation.


Problem B was a typical dynamic programming problem, though its implementation unfortunately took quite a while.

Problem C had an interesting setting. It could be modeled as a random walk with three moves (stay, left, or right), which led to the trinomial coefficients. We had to calculate the equation below for all LNRL\le N\le R.

Query(N)=iN!i!i!(N2i)!pipi(12p)N2iQuery(N)=\sum_i \frac{N!}{i!i!(N-2i)!}p^ip^i(1-2p)^{N-2i}

During the contest, I was unable to find a solution with a time complexity better than O((RL)N)O((R−L)N). It turns out by separating the ii and N2iN−2i terms, the expression forms a convolution that can be solved in O(NlogN)O(N\log N) using the FFT or NTT.

2025 © SEUNGHWAN KIMRSS