hdu4778状态压缩dp 博弈
来源:互联网 发布:淘宝一元拍网址 编辑:程序博客网 时间:2024/05/01 03:07
#include <cstdio>#include <iostream>#include <cstring>using namespace std;int g,b,s;int cc[30][10];int dp[1<<21];int dfs(int status,int num[],int lef){ //cout << status << endl; if(lef == 0) return dp[status] = 0; if(dp[status] != -1) return dp[status]; int tt[10]; int ans = 0; for(int i = 0;i < b;i++){ if(!((status >> i)&1)){ int flag = (status|(1<<i)); int sum = 0; for(int j = 1;j <= g;j++){ tt[j] = num[j] + cc[i][j]; sum += tt[j] / s; tt[j] = tt[j] % s; } int q = 0; if(sum){ q = sum + dfs(flag,tt,lef-sum); //cout << status << " " << "1" << " "<< q << endl; } else{ q = lef - dfs(flag,tt,lef); //cout << status << " " << flag << " " << "2" << " "<< q << endl; } //cout << q << endl; ans = max(ans,q); } } return dp[status] = ans;}int main(){ while(cin >>g>>b>>s,g||b||s){ memset(dp,-1,sizeof(dp)); memset(cc,0,sizeof(cc)); int d[10] = {0}; for(int i = 0;i < b;i++){ int c; scanf("%d",&c); for(int j = 0;j < c;j++){ int x; scanf("%d",&x); cc[i][x]++; d[x] ++; } } int all = 0; for(int i = 1;i <= g;i++){ all += d[i]/s; } //cout << all <<endl; int tt[10] = {0}; int q = dfs(0,tt,all); //cout << q << endl; cout << q - all + q << endl; } return 0;}
0 0
- hdu4778 状态压缩dp+博弈
- hdu4778状态压缩dp 博弈
- 【HDU4778】Gems Fight!-状态压缩DP+博弈
- zoj1039 Number Game 博弈+DP+状态压缩
- hdu 4778 13杭州I题 状态压缩dp+博弈
- hdu4753 状态压缩dp博弈(记忆化搜索写法)
- hdu 4778 Gems Fight! (状态压缩dp+博弈)
- codeforces GYM 101431E (状态压缩dp+博弈)
- hdu5724 Chess 博弈 + 状态压缩
- hdu5724——chess(博弈)(状态压缩dp+sg函数)
- HDU4778
- HDU4778
- 状态压缩dp
- pku1038状态压缩dp
- 状态压缩DP 入门
- HDU1074 状态压缩DP
- Poj3254 状态压缩DP
- 状态压缩DP入门
- O(N^3)找最大子矩阵Submatrix
- BestCoder Round #57 (div.2)HDU 5480 Conturbatio
- leetcode:Add Digits
- 关于软件的自动化测试能否代替软件的手工测试
- 用JAVA做一个用户登入系统
- hdu4778状态压缩dp 博弈
- machine learning2
- Java:详解传值和传引用
- 强大的仿苹果启动器 Cairodock
- POJ-1083 Moving Tables
- Android dex文件通用自动脱壳器
- UNIX环境高级编程——第三章
- C语言函数指针的例子
- 黑马程序员——JAVA之多线程