Recently we were solving problems from past Indian ICPC regional . We weren't able to solve these 2 problems , and I couldn't find any editorial either . It would be really helpful if you guys can give me some hints to these problems.
Chemicals
Description
There are N bottles each having a different chemical. For each chemical i, you have determined C[i], which means that mixing chemicals i and C[i] causes an explosion. You have K distinct boxes. In how many ways can you divide the N chemicals into those boxes such that no two chemicals in the same box can cause an explosion together?
Constraints
- T ≤ 50
- 2 ≤ N ≤ 100
- 2 ≤ K ≤ 1000
My Ideas
I thought of modelling the given dependencies as a graph