Sereja and Permutations 3
Let p be a permutation of integers 1, ..., N. Lets call p good if there is at least one pair of indices (i,j) such that i and p[i] > j, p[j] > i. Sereja is interested in the number of permutations p of 1, ..., N that are good. This might seem easy at first, but Sereja is only interested in permutations that obey a list of M additional rules. Rule number i (1 ≤ i ≤ M) in Sereja's list says p(Xi) s
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