Problem 1434 · Hard

Number of Ways to Wear Different Hats to Each Other

Process hats one at a time with a bitmask of the people already wearing one, so every hat is used at most once.

Open the interactive visualisation