bzoj[JLOI2011]飞行路线
来源:互联网 发布:人人贷网络p2p借贷 编辑:程序博客网 时间:2024/05/23 00:05
今天听了tyb师兄的讲课,就A了这道水水的spfa。。。只是一维变成二维而已。。。
#include<cstdio>#include<cstring>using namespace std;struct node{ int x,y,d,next;}a[210000];int len,last[110000];void ins(int x,int y,int d){ len++; a[len].x=x;a[len].y=y;a[len].d=d; a[len].next=last[x];last[x]=len;}struct linode{ int x,tp;}list[210000];int d[11000][20];bool v[11000][20];int main(){ int n,m,K,st,ed,x,y,c; scanf("%d%d%d",&n,&m,&K); scanf("%d%d",&st,&ed);st++;ed++; len=0;memset(last,0,sizeof(last)); for(int i=1;i<=m;i++) { scanf("%d%d%d",&x,&y,&c);x++;y++; ins(x,y,c);ins(y,x,c); } memset(v,false,sizeof(v));v[st][0]=true; for(int i=1;i<=n;i++)for(int j=0;j<=K;j++)d[i][j]=99999999; d[st][0]=0;list[1].x=st;list[1].tp=0; int head=1,tail=2,ans=99999999; while(head!=tail) { x=list[head].x;int tp=list[head].tp; if(x==ed){if(d[x][tp]<ans)ans=d[x][tp];} for(int k=last[x];k;k=a[k].next) { y=a[k].y; if(d[y][tp]>d[x][tp]+a[k].d) { d[y][tp]=d[x][tp]+a[k].d; if(v[y][tp]==false) { v[y][tp]=true; list[tail].x=y;list[tail].tp=tp; tail++;if(tail==200001)tail=1; } } if(tp+1<=K&&d[y][tp+1]>d[x][tp]) { d[y][tp+1]=d[x][tp]; if(v[y][tp+1]==false) { v[y][tp+1]=true; list[tail].x=y;list[tail].tp=tp+1; tail++;if(tail==200001)tail=1; } } } v[x][tp]=false; head++;if(head==200001)head=1; } printf("%d\n",ans); return 0;}
By_yzh
0 1
- bzoj[JLOI2011]飞行路线
- 【BZOJ】【JLOI2011】飞行路线
- BZOJ 2763: [JLOI2011]飞行路线
- bzoj 2763 [JLOI2011]飞行路线
- BZOJ 2763 [JLOI2011]飞行路线
- BZOJ 2763 [JLOI2011]飞行路线
- bzoj 2763: [JLOI2011]飞行路线
- bzoj 2763: [JLOI2011]飞行路线
- BZOJ 2763 [JLOI2011]飞行路线
- BZOJ 2763 [JLOI2011]飞行路线 Dijikstra
- BZOJ 2763: [JLOI2011]飞行路线 最短路
- |BZOJ 2763|最短路|[JLOI2011]飞行路线
- bzoj 2763 [JLOI2011]飞行路线 Dijikstra 分层
- BZOJ[2763][JLOI2011]飞行路线 spfa
- 【JLOI2011】【BZOJ2763】飞行路线
- BZOJ2763: [JLOI2011]飞行路线
- [JLOI2011]飞行路线
- bzoj2763【JLOI2011】飞行路线
- Oracledbconsoleorcl启动不了,本地连接数据库失败
- iOS那些简单的动画,属性详解和转场动画
- Android文字跑马灯控件(文本自动滚动控件,左右移动 带源码)
- Handler
- Android自定义View-TitleBar(标题栏)详细说明
- bzoj[JLOI2011]飞行路线
- 3.PN结
- CreateJS框架初探
- Codeforces Beta Round #22 (Div. 2 Only)-B. Bargaining Table
- 025.自定义View中应用贝塞尔曲线
- forward的细节(2)
- bochs安装(ubuntu)
- Xamarin.iOS调试提示需要iOS SDK
- X264码率控制总结1——ABR,CQP,CRF