bzoj5056: OI游戏
来源:互联网 发布:东莞制造业知乎 编辑:程序博客网 时间:2024/06/07 15:45
我们van♂游戏233。
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>using namespace std;queue<int> q;int read(){ char ch=getchar();int f=0; while(ch<'0'||ch>'9')ch=getchar(); while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();} return f;}struct node{ int from; int to; int next; int w;}edge[50005];int tot1=0,head[1005],n,m,dis[1005];bool vis[1005];char s[5005];const int mod=1000000007;void add(int u,int v,int w){ edge[tot1].from=u; edge[tot1].to=v; edge[tot1].w=w; edge[tot1].next=head[u]; head[u]=tot1++;}void spfa(){ q.push(1); dis[1]=0; while(!q.empty()) { int x=q.front(); q.pop();vis[x]=0; for(int i=head[x];i!=-1;i=edge[i].next) { if(dis[edge[i].to]>dis[x]+edge[i].w) { dis[edge[i].to]=dis[x]+edge[i].w; if(!vis[edge[i].to]) { q.push(edge[i].to); vis[edge[i].to]=1; } } } }}void solve(){ long long ans=1; for(int i=2;i<=n;i++) { long long tot=0; for(int j=head[i];j!=-1;j=edge[j].next) { if((long long)dis[i]==(long long)dis[edge[j].to]+(long long)edge[j].w) tot++; } //cout<<tot<<" "; ans=ans*tot%mod; } cout<<ans;}int main(){ memset(head,-1,sizeof(head)); memset(dis,0x7f7f7f7f,sizeof(dis)); n=read(); for(int i=1;i<=n;i++) { scanf("%s",s+1); for(int j=1;j<=n;j++) { if(s[j]!='0') { add(i,j,s[j]-'0'); } } } spfa(); //for(int i=1;i<=n;i++) //cout<<dis[i]<<" "; solve();}
阅读全文
0 0
- 【bzoj5056】OI游戏
- bzoj5056: OI游戏
- bzoj 5056: OI游戏
- bzoj 5056: OI游戏
- bzoj 5056: OI游戏
- wiki oi 1051 接龙游戏
- 维基oi 3285 转圈游戏
- 【OI做题记录】【BZOJ】【Scoi2010】游戏
- OI
- Oi
- OI? OI!
- 2007OI, 矩阵取数游戏( 区间DP )
- 【OI做题记录】【BZOJ】【Ahoi2014】骑士游戏
- BZOJ 5056 OI游戏 (最短路径树)
- BZOJ 5056 OI游戏 dijkstra(最短路径的数目)
- kl;oi;
- OI算法
- OI知识点
- CSS 继承
- 记忆网络之Gated End-To-End Memory Networks
- MySQL explain执行计划解读
- 一个简单地程序示例剖析类加载机制
- 洛谷 3932 浮游大陆的68号岛 前缀和
- bzoj5056: OI游戏
- 手把手教Redis安装
- 刷题#R10
- 阿里云ECS的1M带宽能干嘛?
- 编写服务器和客户端
- 百度前端技术学院-任务四模拟队列
- Windows环境搭建Tomcat+Nginx的负载均衡and动静资源分离
- 【codevs 3377】[Mz]接水问题2
- PyTorch笔记1-PyTorch简介