HDU 1839 Delay Constrained Maximum Capacity Path
来源:互联网 发布:网络卖淫产业链 编辑:程序博客网 时间:2024/06/08 16:40
Delay Constrained Maximum Capacity Path
Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 1158 Accepted Submission(s): 354
Problem Description
Consider an undirected graph with N vertices, numbered from 1 to N, and M edges. The vertex numbered with 1 corresponds to a mine from where some precious minerals are extracted. The vertex numbered with N corresponds to a minerals processing factory. Each edge has an associated travel time (in time units) and capacity (in units of minerals). It has been decided that the minerals which are extracted from the mine will be delivered to the factory using a single path. This path should have the highest capacity possible, in order to be able to transport simultaneously as many units of minerals as possible. The capacity of a path is equal to the smallest capacity of any of its edges. However, the minerals are very sensitive and, once extracted from the mine, they will start decomposing after T time units, unless they reach the factory within this time interval. Therefore, the total travel time of the chosen path (the sum of the travel times of its edges) should be less or equal to T.
Input
The first line of input contains an integer number X, representing the number of test cases to follow. The first line of each test case contains 3 integer numbers, separated by blanks: N (2 <= N <= 10.000), M (1 <= M <= 50.000) and T (1 <= T <= 500.000). Each of the next M lines will contain four integer numbers each, separated by blanks: A, B, C and D, meaning that there is an edge between vertices A and B, having capacity C (1 <= C <= 2.000.000.000) and the travel time D (1 <= D <= 50.000). A and B are different integers between 1 and N. There will exist at most one edge between any two vertices.
Output
For each of the X test cases, in the order given in the input, print one line containing the highest capacity of a path from the mine to the factory, considering the travel time constraint. There will always exist at least one path between the mine and the factory obbeying the travel time constraint.
Sample Input
22 1 101 2 13 104 4 201 2 1000 152 4 999 61 3 100 153 4 99 4
Sample Output
1399
Author
Mugurel Ionut Andreica
解题思路:二分一下边上的限制条件,做最短路
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<queue>#define Inf 9999999999using namespace std;int head[10005],k;long long dis[10005];struct{ int e; int c; int t; int next;}edge[100005];void add(int s,int e,int c,int t){ edge[k].e=e; edge[k].c=c; edge[k].t=t; edge[k].next=head[s]; head[s]=k++;}void spfa(int w,int n){ int i,st,ed; bool visit[10005]; queue<int> x; memset(visit,false,sizeof(visit)); for(i=0;i<=n;i++) dis[i]=Inf; x.push(1); dis[1]=0; while(!x.empty()) { st=x.front(); x.pop(); visit[st]=false; for(i=head[st];i!=-1;i=edge[i].next) { ed=edge[i].e; if(dis[ed]>=dis[st]+edge[i].t&&edge[i].c>=w) { dis[ed]=dis[st]+edge[i].t; if(!visit[ed]) { visit[ed]=true; x.push(ed); } } } }}int main(){ int s,i,m,n,time,a,b,c,t,ans,l,r,w[50005]; scanf("%d",&s); while(s--) { scanf("%d%d%d",&n,&m,&time); k=i=0; memset(head,-1,sizeof(head)); while(m--) { scanf("%d%d%d%d",&a,&b,&c,&t); add(a,b,c,t); add(b,a,c,t); w[i++]=c; } sort(w,w+i); l=0;r=i-1; while(r>=l) { int mid=(l+r)>>1; spfa(w[mid],n); if(dis[n]<=time) { l=mid+1; ans=w[mid]; } else r=mid-1; } printf("%d\n",ans); }}
0 0
- hdu 1839 Delay Constrained Maximum Capacity Path
- hdu 1839 Delay Constrained Maximum Capacity Path
- hdu 1839:Delay Constrained Maximum Capacity Path
- HDU 1839 Delay Constrained Maximum Capacity Path
- HDU 1839 Delay Constrained Maximum Capacity Path
- HDU 1839 Delay Constrained Maximum Capacity Path
- HDU-1839-Delay Constrained Maximum Capacity Path
- Delay Constrained Maximum Capacity Path HDU
- Delay Constrained Maximum Capacity Path HDU
- HDU 1839 Delay Constrained Maximum Capacity Path(二分+最短路)
- HDU-1839 Delay Constrained Maximum Capacity Path 最短路
- HDU-1839 Delay Constrained Maximum Capacity Path 最短路+二分
- HDU 1839 Delay Constrained Maximum Capacity Path 最短路+二分
- 【HDU】1839 Delay Constrained Maximum Capacity Path 二分+最短路
- hdu 1839 Delay Constrained Maximum Capacity Path 二分+ spfa
- HDU 1839 Delay Constrained Maximum Capacity Path 最短路+二分
- HDU 1839 Delay Constrained Maximum Capacity Path(最短路+二分)
- HDU 1839 Delay Constrained Maximum Capacity Path(二分+SPFA)
- 第01课 OpenGL窗口(3)
- 2015年网易校招Java开发工程师(技术架构)在线笔试题(2015年9月20日 18:00—20:00)
- HDOJ 5019 Revenge of GCD
- Apk调试过程细节
- 【面试】经典面试题,你会做几道(持续更新)
- HDU 1839 Delay Constrained Maximum Capacity Path
- HDOJ 5038 Grade
- 唯品会2015校园招聘技术岗附加题解答
- Java垃圾收集器与内存分配策略
- Codeforces Round #268 (Div. 2)
- execv使用
- Java之父 James Gosling 发表博文 《Too Soon》纪念乔布斯。
- oracle ebs hrms 接口程序
- CoreOS宣布收购Quay.io并启动了CoreOS企业Registry