hdu 1839 Delay Constrained Maximum Capacity Path 二分/最短路
Delay Constrained Maximum Capacity Path
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=1839
Description
Input
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
2
2 1 10
1 2 13 10
4 4 20
1 2 1000 15
2 4 999 6
1 3 100 15
3 4 99 4
Sample Output
13
99
HINT
题意
题解:
二分cap,然后直接最短路判断就好了
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 500001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x7fffffff;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int n,m,t;
struct node
{
int x;
ll y;
int z;
};
bool cmp(ll a,ll b)
{
return a>b;
}
vector<node> e[maxn];
ll c[maxn];
int inq[maxn];
int d[maxn];
int solve(int x)
{
for(int i=;i<=n;i++)
d[i]=inf;
d[]=;
queue<int> q;
q.push();
while(!q.empty())
{
int v=q.front();
q.pop();
for(int i=;i<e[v].size();i++)
{
if(e[v][i].y>=x)
{
if(d[e[v][i].x]>d[v]+e[v][i].z)
{
d[e[v][i].x]=d[v]+e[v][i].z;
q.push(e[v][i].x);
}
}
}
}
return d[n];
}
int main()
{
//test;
int T=read();
while(T--)
{
n=read(),m=read(),t=read();
for(int i=;i<maxn;i++)
e[i].clear();
memset(c,,sizeof(c));
for(int i=;i<m;i++)
{
int a=read(),b=read();
c[i]=read();
int d=read();
e[a].push_back((node){b,c[i],d});
e[b].push_back((node){a,c[i],d});
}
sort(c,c+m,cmp);
int l=,r=m-,mid;
while(l<r)
{
mid=(l+r)/;
int tmp=c[mid];
if(solve(tmp)>t)
l=mid+;
else
r=mid;
}
cout<<c[l]<<endl;
}
}
hdu 1839 Delay Constrained Maximum Capacity Path 二分/最短路的更多相关文章
- hdu 1839 Delay Constrained Maximum Capacity Path(spfa+二分)
Delay Constrained Maximum Capacity Path Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65 ...
- hdu 1839 Delay Constrained Maximum Capacity Path
最短路+二分. 对容量进行二分,因为容量和时间是单调关系的,容量越多,能用的边越少,时间会不变或者增加. 因为直接暴力一个一个容量去算会TLE,所以采用二分. #include<cstdio&g ...
- HDU 2254 奥运(矩阵高速幂+二分等比序列求和)
HDU 2254 奥运(矩阵高速幂+二分等比序列求和) ACM 题目地址:HDU 2254 奥运 题意: 中问题不解释. 分析: 依据floyd的算法,矩阵的k次方表示这个矩阵走了k步. 所以k ...
- 【启发式搜索】Codechef March Cook-Off 2018. Maximum Tree Path
有点像计蒜之道里的 京东的物流路径 题目描述 给定一棵 N 个节点的树,每个节点有一个正整数权值.记节点 i 的权值为 Ai.考虑节点 u 和 v 之间的一条简单路径,记 dist(u, v) 为其长 ...
- Codechef March Cook-Off 2018. Maximum Tree Path
目录 题意 解析 AC_code @(Codechef March Cook-Off 2018. Maximum Tree Path) 题意 给你一颗\(n(1e5)\)个点有边权有点权的树,\(Mi ...
- 二分+最短路 UVALive - 4223
题目链接:https://vjudge.net/contest/244167#problem/E 这题做了好久都还是超时,看了博客才发现可以用二分+最短路(dijkstra和spfa都可以),也可以用 ...
- 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举
2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举 ...
- 二分+最短路 uvalive 3270 Simplified GSM Network(推荐)
// 二分+最短路 uvalive 3270 Simplified GSM Network(推荐) // 题意:已知B(1≤B≤50)个信号站和C(1≤C≤50)座城市的坐标,坐标的绝对值不大于100 ...
- BZOJ_1614_ [Usaco2007_Jan]_Telephone_Lines_架设电话线_(二分+最短路_Dijkstra/Spfa)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1614 分析 类似POJ_3662_Telephone_Lines_(二分+最短路) Dijks ...
随机推荐
- Linux服务部署
1. 构建NTP时间服务器 NTP服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服务器与时间服务器的时间保持一致,某些应用对时间实时性要求高的必须统一时间.互联网的时间服务器也有很多,例 ...
- LR之脚本调试
1.概述 2.Animated run和Non-animated run 3.调试小技巧 4.日志设置
- php 页面参数过多时自动拼接get参数的函数
function getUri($query){ $request_uri = $_SERVER["REQUEST_URI"]; $url = strstr($request_ur ...
- java int和String类型之间的相互转换
String --> int 第一种方法:int i = Integer.parseInt(s); 第二种方法:int i = Integer.valueOf(s).intValue(); 两种 ...
- 【boost】使用装饰者模式改造boost::thread_group
在项目中使用boost::thread_group的时候遇到几个问题: 1.thread_group不提供删除全部thread列表的方法,一直使用create会是其内部列表不断增加. 2.thread ...
- Uva 11183 - Teen Girl Squad (最小树形图)
Problem ITeen Girl Squad Input: Standard Input Output: Standard Output You are part of a group of n ...
- html5 拖拽
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- Matlab 图像画在坐标轴下
>> x=linspace(,*pi,); >> y=sin(x); >> figure;plot(x,y,'r-') >> set(gca,'xaxi ...
- IE8-模拟script onerror
利用VBScript 检测,有副作用,慎用! var loadScript = function () { var DOC = document, HEAD = document.getElement ...
- Clean Code第二章<命名>
1.命名要有意义 错误写法 正确写法 2.某些构造函数可以提供有意义的静态方法去实现