BZOJ 3036: 绿豆蛙的归宿|概率与期望
2016-01-20 17:24
267 查看
数组开小了wa了好几发
开始没有发现这个sb错误然后各种yy
比如说以下情况,出现一些走不到终点的点
画的好丑……………………
数据似乎并没有这种情况
然后就是最水的概率dp了
开始没有发现这个sb错误然后各种yy
比如说以下情况,出现一些走不到终点的点
画的好丑……………………
数据似乎并没有这种情况
然后就是最水的概率dp了
#include<set> #include<map> #include<ctime> #include<queue> #include<cmath> #include<cstdio> #include<vector> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #define T 111111 using namespace std; int sc() { int i=0,f=1; char c=getchar(); while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9')i=i*10+c-'0',c=getchar(); return i*f; } double F[T],D[T]; int head[T],lst[T*2],nxt[T*2],v[T*2],d[T]; int n,m,tot; queue<int>q; void insert(int x,int y,int z) { lst[++tot]=y; nxt[tot]=head[x]; v[tot]=z; head[x]=tot; } int main() { n=sc(),m=sc(); for(int i=1;i<=m;i++) { int x=sc(),y=sc(),z=sc(); insert(y,x,z); d[x]++; } for(int i=1;i<=n;i++)D[i]=d[i]?d[i]:1; q.push(n); while(!q.empty()) { int x=q.front();q.pop(); F[x]/=D[x]; for(int i=head[x];i;i=nxt[i]) { d[lst[i]]--; F[lst[i]]+=(F[x]+v[i]); if(!d[lst[i]]) q.push(lst[i]); } } printf("%.2lf",F[1]); return 0; }
相关文章推荐
- 1076: [SCOI2008]奖励关|状压动规|概率与期望
- 3450: Tyvj1952 Easy|概率与期望
- 2318: Spoj4060 game with probability Problem|概率与期望
- 2134: 单选错位|概率与期望
- 3191: [JLOI2013]卡牌游戏|概率与期望
- [HDU4035]Maze(概率与期望)
- [Codeforces335E]Counting Skyscrapers(概率期望+数学证明)
- [BZOJ3036][绿豆蛙的归宿][期望与概率+DP]
- [BZOJ3925][[Zjoi2015]地震后的幻想乡][期望+状压DP]
- Bzoj1419 Red is good
- Hdu 4465 Candy
- Codeforces Round #363 (Div. 1) C LRU
- Codeforces Round #362 (Div. 1) C PLEASE
- Codeforces Round #362 (Div. 1) B Puzzles
- 【NOIP2016提高组】换教室
- Codeforces 280 C. Game on Tree (概率与期望)
- HDU 4254 A Famous Game(概率与期望)
- Bzoj3270:博物馆:概率与期望,高斯消元
- Bzoj3566:[SHOI2014]概率充电器:概率dp
- BZOJ 1419: Red is good|期望Dp