#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 110
#define db double 
using namespace std;

int n,m,nd[N],v[N];
db f[N][1<<16];

inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

db DP(int i,int S){
	if(i>m) return 0;
	db &tmp=f[i][S];
	if(tmp+1e9>1e-9) return tmp;
	tmp=0;
	for(int j=1;j<=n;++j)
		if((S|nd[j])==S)
			tmp+=max(DP(i+1,S),DP(i+1,S|(1<<(j-1)))+v[j]);
		else tmp+=DP(i+1,S);	
	tmp/=n;
	return tmp;
}

int main(){
	m=read(),n=read();
	for(int i=1;i<=n;++i){
		v[i]=read();
		for(int x=read();x!=0;x=read()) nd[i]|=(1<<(x-1));
	}
	for(int i=0;i<=m;++i)for(int j=0;j<(1<<n);++j)f[i][j]=-2e9;
	printf("%.6lf\n",DP(1,0));
}

 

相关文章:

  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2021-09-24
  • 2022-01-21
  • 2022-03-04
猜你喜欢
  • 2022-01-15
  • 2022-02-07
  • 2021-09-07
  • 2021-08-04
  • 2021-12-21
相关资源
相似解决方案