TYVJ 1211 跳舞家怀特先生(DP)
来源:互联网 发布:mac系统 怎么看文件夹 编辑:程序博客网 时间:2024/05/01 21:31
连接:http://new.tyvj.cn/Problem_Show.aspx?id=1211
思路:dp[k][i][j] 表示第k步,第一只脚在i点,第二只脚在j点。。一次只能变一只脚。。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <stack>using namespace std;const int INF = 0x3f3f3f3f;int dp[10009][5][5];int oor(int a,int b){ if(a==0) return 2; if(a==b) return 1; if((a+b)&1) return 3; else return 4;}int main(){ freopen("in.txt","r",stdin); int n,t; scanf("%d",&n); memset(dp,INF,sizeof(dp)); dp[0][0][0]=0; for(int k=1;k<=n;k++) { scanf("%d",&t); for(int i=0;i<5;i++) for(int j=0;j<5;j++) dp[k][i][t] = min(dp[k-1][i][j]+oor(j,t),dp[k][i][t]); for(int i=0;i<5;i++) for(int j=0;j<5;j++) dp[k][t][j] = min(dp[k-1][i][j]+oor(i,t),dp[k][t][j]); } int ans=INF; for(int i=0;i<5;i++) for(int j=0;j<5;j++) ans=min(ans,dp[n][i][j]); printf("%d\n",ans); return 0;}
- TYVJ 1211 跳舞家怀特先生(DP)
- 【DP】tyvj P1211 - 跳舞家怀特先生
- 信息学竞赛DP专题(一)BNU8207舞蹈家怀特先生
- 舞蹈家怀特先生 tyvj1211
- 黑书 舞蹈家怀特先生
- “舞蹈家”怀特先生(Dance Dance Revolution)
- Tyvj 1211 DP
- 跳舞 纪中2545 dp
- tyvj-1034 DP
- tyvj-1044 DP
- tyvj-1045 DP
- tyvj-1048 DP
- tyvj-1050 LCS DP
- tyvj-1052 树形DP
- tyvj-1055 区间DP
- tyvj-1144 股票 DP
- tyvj-1084 简单DP
- [TYVJ-1088] DP
- 百年一遇的奇怪问题:当IE遇上.NET Framework 4.5
- 推荐网页设计师和开发人员使用的10个云应用
- 8088段和偏移
- 变量绑定和sql_trace
- UILabel光晕Demo
- TYVJ 1211 跳舞家怀特先生(DP)
- UART驱动过程
- TTL电平和232电平
- C#中通过读取配置文件动态创建泛型对象
- 那年,那场青春繁华梦
- ORacle函数(转载)
- dms代码
- 如何取消服务器/主机空间目录脚本的执行权限(apache)
- netstat ss tcpdump查看网络信息相关命令