eolymp
bolt
Try our new interface for solving problems
Məsələlər

Avoiding Partitions

Avoiding Partitions

\includegraphics{https://static.e-olymp.com/content/c3/c3f9ed8e48c92a5a2a841d0ad412343541a6a236.jpg} \includegraphics{https://static.e-olymp.com/content/4a/4a84637a3e45784a6f542dae8121ca18138bc8e6.jpg} A partition of a set \textbf{S = \{1, 2, ..., n\}} is a collection \textbf{P} of sets \textbf{P = \{P_1, P_2, ..., P_k\}} such that U\textbf{P_i} = \textbf{S} and \textbf{P_i} \textbf{P_j} = for \textbf{i}≠\textbf{j}. An example of a partition for \textbf{n = 5} is \textbf{P_1} = \textbf{\{1, 3\}}, \textbf{P_2} = \textbf{\{2, 4, 5\}}. The partition is said to avoid set \textbf{Q} if none of \textbf{P_i} has \textbf{Q} as a subset. For example, the partition above avoids sets \textbf{\{1, 2\}} and \textbf{\{3, 4\}} but doesn't avoid \textbf{\{1, 3\}} nor \textbf{\{2\}}. Given \textbf{n} and a collection of sets \textbf{Q_1}, \textbf{Q_2}, ..., \textbf{Q_l} find the number of partitions of \textbf{S} that avoid each of \textbf{Q_i}. \InputFile The first line of the input file contains two integer numbers \textbf{n} and \textbf{l} (\textbf{1} ≤ \textbf{n} ≤ \textbf{100}, \textbf{0} ≤ \textbf{l} ≤ \textbf{10}). The following \textbf{l} lines describe sets to avoid. Each line starts with one integer number \textbf{q_i} - the size of the set, followed by \textbf{q_i} numbers - the elements of the set. \OutputFile Output one integer number the number of partitions avoiding each of \textbf{Q_i}.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
5 2
3  1 2 3
2  2 4
Çıxış verilənləri #1
34
Müəllif Andrew Stankevich
Mənbə Andrew Stankevich Contest 32, Petrozavodsk Summer Training Camp, Wednesday, September 3, 2008