← All problemsSign in

Too Many LIS

CodeChefRating 2906Open on judge ↗

You are given $2$ integers $N$ and $M$. You also have an empty set $S$. Consider an array $A$ of length $N$ such that $1 \leq A_i \leq M$ for each $1 \leq i \leq N$ (there are $M^N$ such arrays in total). For each of these $M^N$ arrays, insert **all** of its longest non-decreasing subsequences into $S$. Output the size of $S$. Since the size of $S$ might be large, output it modulo $10^9+7$. N

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start