标签:lte size des 颜色 produce sea als div hid
Input
Output
Sample Input
Sample Output
Source
1 #include<bits/stdc++.h> 2 using namespace std; 3 const int N=25,M=10; 4 int G,B,S,n,x,a[N],b[N],c[N][M],f[(1<<21)+5]; 5 int main() 6 { 7 while ((scanf("%d%d%d",&G,&B,&S))&&(G+B+S)) 8 { 9 memset(c,0,sizeof(c)); 10 for (int i=0;i<B;++i) 11 { 12 scanf("%d",&n); 13 for (int j=1;j<=n;++j) 14 { 15 scanf("%d",&x); 16 ++c[i][x]; 17 } 18 } 19 f[0]=0; 20 for (int i=1;i<(1<<B);++i) 21 { 22 f[i]=-1e9; 23 memset(a,0,sizeof(a)); 24 for (int j=0;j<B;++j) 25 if ((i&(1<<j))==0) 26 { 27 for (int k=1;k<=G;++k) 28 a[k]+=c[j][k],a[k]%=S; 29 } 30 for (int j=0;j<B;++j) 31 if (i&(1<<j)) 32 { 33 for (int k=1;k<=G;++k) b[k]=a[k]; 34 int cnt=0; 35 for (int k=1;k<=G;++k) 36 b[k]+=c[j][k],cnt+=b[k]/S,b[k]%=S; 37 if (cnt) f[i]=max(f[i],cnt+f[i^(1<<j)]); 38 else f[i]=max(f[i],-f[i^(1<<j)]); 39 } 40 } 41 printf("%d\n",f[(1<<B)-1]); 42 } 43 return 0; 44 }
标签:lte size des 颜色 produce sea als div hid
原文地址:http://www.cnblogs.com/zk1431043937/p/7765497.html