← All problemsSign in

Combinatorics Is Fun

CodeChefRating 3210Open on judge ↗

Stack has $N$ distinct cards, numbered $1$ to $N$. He wonders how many pairs of arrays $(A,B)$ are there such that: - $|A|=|B|=N$; - $1 \leq A_i, B_i \leq N$; - $A_i \neq B_i$; - If he writes $A_i$ on the upper face of $i^{th}$ card and $B_i$ on the lower face of $i^{th}$ card, it is possible to flip some of the cards in such a way that each integer from $1$ to $N$ is present on the upper face of

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