zoj 3305 Get Sauce

zoj 3305 Get Sauce,第1张

zoj 3305 Get Sauce
#include <cstdio>#include <cstring>#include <iostream>#include <vector>#include <set>#include <algorithm>using namespace std;int dp[1<<16] ;int n , m ;int main(){ while (scanf("%d%d",&n,&m)==2){ for (int i = 0 ; i < (1<<n) ; i++) dp[i]=0; for (int i = 0 ; i < m ; i++){ int k = 0 , st = 0 ; scanf("%d",&k); for (int j = 0 ; j < k ; j++){ int tmp ; scanf("%d",&tmp); st |= (1<<(tmp-1)) ; } dp[st]=1 ; } int ans=0; for (int i = 1 ; i <(1<<n) ; i++){ for (int j = (i-1)&i ; j != 0 ; j = (j-1)&i){ dp[i] = max(dp[i] , dp[j] + dp[i^j]); } ans = max(ans,dp[i]); } printf("%dn",ans); } return 0 ;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4891307.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存