【DP 训练】Free Candies, UVa 10118
来源:互联网 发布:商品降价提醒软件 编辑:程序博客网 时间:2024/06/01 10:41
#include<bits/stdc++.h>using namespace std;int n,dp[50][50][50][50],pile[5][50],top[5];int dfs(int cur,int status){if(cur==5)return 0;int& ans = dp[top[1]][top[2]][top[3]][top[4]];if(ans!=-1)return ans;ans = 0;for(int i=1;i<=4;i++){if(top[i]==n)continue;++top[i];if(status&1<<pile[i][top[i]])ans = max(ans,dfs(cur-1,status^1<<pile[i][top[i]])+1);else ans = max(ans,dfs(cur+1,status^1<<pile[i][top[i]]));--top[i];}return ans;}int main(void){while(scanf("%d",&n)&&n){for(int i=1;i<=n;i++){for(int j=1;j<=4;j++){cin>>pile[j][i];}}memset(top,0,sizeof(top));memset(dp,-1,sizeof(dp));cout<<dfs(0,0)<<endl;}return 0;}
1 0
- 【DP 训练】Free Candies, UVa 10118
- Free Candies - UVa 10118 dp
- uva 10118 (Free Candies)(DP)
- UVA - 10118 Free Candies(dp)
- UVa 10118 - Free Candies(dp)
- UVa 10118:Free Candies(DP)
- uva 10118 Free Candies dp(分析+状压)
- uva 10118 Free Candies
- uva 10118 - Free Candies
- UVA - 10118 Free Candies
- uva 10118 - Free Candies
- UVA 10118 - Free Candies
- UVA - 10118 Free Candies
- UVA - 10118 Free Candies
- UVa 10118 Free Candies
- uva 10118 free candies
- UVA 10118 Free Candies
- UVA 10118 Free Candies
- 欢迎使用CSDN-markdown编辑器
- 搜索算法-求解最大子数组
- 线性表
- 设计模式(三)创建型模式
- 顺丰科技2017笔试 小C负责设计一种新的益智数字游戏
- 【DP 训练】Free Candies, UVa 10118
- 8086寄存器简述
- 使用Scala Parser解析JSON
- 子图同构问题Ullmann 算法(二)
- C++ map 容器
- console使用
- 创建和启动线程的两种方式
- Qt发布程序
- 销毁session