博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UESTC 电子科大专题训练 DP-E
阅读量:4604 次
发布时间:2019-06-09

本文共 1107 字,大约阅读时间需要 3 分钟。

题意:中文题

思路:遍历每一公里,然后计算每个车道对后一公里做出的贡献,最边上的车道特判,如果计算当前车道可以由前1公里的哪些车道做出贡献那么需要特判很多,但是如果计算当前车道对后1公里做出的贡献只需要特判最边上2个车道即可,遍历完所有车道后判断如果车道上有障碍,那么这公里的的这个车道的概率为0,数据比较水,如果数据大可以用矩阵快速幂对每2个障碍之间用矩阵快速幂优化,这里就不写了

AC代码:

#include "iostream"#include "iomanip"#include "string.h"#include "stack"#include "queue"#include "string"#include "vector"#include "set"#include "map"#include "algorithm"#include "stdio.h"#include "math.h"#define ll long long#define bug(x) cout<
<<" "<<"UUUUU"<
pp[1005];int main(){ //ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>m>>k>>n>>p; for(int i=1; i<=k; ++i){ cin>>a>>b; pp[b].pb(a); ma=max(ma,b); } dp[0][p]=1; double *now=dp[0], *nex=dp[1]; for(int i=1; i<=ma; ++i){ for(int j=1; j<=m; ++j){ if(j==1){ nex[j]+=now[j]/2; nex[j+1]+=now[j]/2; } else if(j==m){ nex[j]+=now[j]/2; nex[j-1]+=now[j]/2; } else{ nex[j]+=now[j]/3; nex[j+1]+=now[j]/3; nex[j-1]+=now[j]/3; } } for(auto j : pp[i]){ nex[j]=0; } swap(now,nex); memset(nex,0,sizeof(dp[0])); } for(int i=1; i<=m; ++i){ ans+=now[i]; } printf("%.6f\n",ans); return 0;}

 

转载于:https://www.cnblogs.com/max88888888/p/7230808.html

你可能感兴趣的文章
xp_cmdshell 命令的开启与关闭,和状态查询
查看>>
Linux sudoers
查看>>
MySQL详解(18)-----------分页方法总结
查看>>
bzoj 4595 激光发生器
查看>>
multi cookie & read bug
查看>>
js时间转换
查看>>
(转载) Android Studio你不知道的调试技巧
查看>>
POJ2231 Moo Volume 递推 C语言
查看>>
struts2类型转换的具体流程
查看>>
Hdu 1203 I NEED A OFFER!
查看>>
php文件上传类
查看>>
CF219D Choosing Capital for Treeland
查看>>
luogu P3809 【模板】后缀排序
查看>>
JVM 调优工具
查看>>
SCTF 2014 pwn题目分析
查看>>
集合以及特殊集合
查看>>
USACO 2.2 Runaround Numbers
查看>>
Matlab画图-非常具体,非常全面
查看>>
365. Water and Jug Problem
查看>>
SQL数据库数据检索top和distinct
查看>>