| Class Clothing |
| Difficulty level: C; operating time limit: 1000ms; operating space limit: 256000KB; code length limit: 2000000B |
| Question Description |
To have a sports meeting, God Ben School of n classes to choose class clothing, there are 100 types of class clothing, numbering 1~100. Each class now has a selection of styles to choose from, with a maximum of 100 styles to choose from each class. Require each class to eventually select a style as a class, and the style of the class can not be the same as other classes, the total number of possible programs, as the total number of scenarios may be large, so the output mod 1000000007 after the answer. |
| Input |
A total of T-group data. For each set of data, the first behavior is an integer n, which indicates that there are n classes. 2~n+1 line with a maximum of 100 digits per line indicating the number of class I-1 to be selected. |
| Output |
| For each set of data, the output scenario totals mod 1000000007 after the answer. |
| Input example |
2 3 5 100 1 2 5 100 2 3 5 8 100 |
| Output example |
4 4 |
| Other Notes |
For 30% of data, 1<=t<=3, 1<=n<=3, each class to choose a style of no more than 10. For 50% of data, 1<=t<=5, 1<=n<=5, each class to choose a style of no more than 50. For 100% of data, 1<=t<=10, 1<=n<=10, each class to choose a style of no more than 100. |
#include <cstdio>
#include <cctype>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#define REP (i,s,t) for (int i=s;i<=t;i++)
#define DWN (I,S,T) for (int i=s;i>=t;i--)
#define REN for (int i=first[x];i!=-1;i=next[i])
using namespace Std;
int yes;
inline int read () {
int X=0,f=1;char C=getchar ();
for (;! IsDigit (c); C=getchar ()) if (c== '-') f=-1;
for (; IsDigit (c); C=getchar ()) x=x*10+c-' 0 ';
if (c== ' \ n ') Yes=1;
return x*f;
}
const int mod=1000000007;
int a[110],f[110][1050];
int main () {
F[0][0]=1;
Dwn (T,read (), 1) {
memset (a,0,sizeof (A));
int N=read ();
Rep (i,1,n) {
yes=0;
while (!yes) A[read ()]|=1<<i-1;
}
Rep (i,1,100) Rep (s,0, (1<<n)-1) {
F[i][s]=f[i-1][s];
Rep (j,0,n-1) if ((a[i]>>j&1) && (s>>j&1)) (f[i][s]+=f[i-1][s^ (1<<J)])%=mod;
}
printf ("%d\n", f[100][(1<<n)-1]);
}
return 0;
}
Benser (c + +)