Permutation Composition Queries
You are given $N$ sequences $P_1, P_2, \dots, P_N$. Each of them is a permutation of numbers $1$ through $M$. Let's define a product of two permutations $X$ and $Y$ of numbers $1$ through $M$ as a permutation $Z = X\cdot Y$ such that $Z_i=Y_{X_i}$ for each valid $i$. You should answer $Q$ queries. Each query is described by two numbers $L$ and $R$. Let's define a permutation $B = P_L \cdot P_{L+
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.
Sign in to chat with the tutor and save your progress.
Sign in to start