[USACO07NOV]牛栏Cow Hurdles
OJ题号:洛谷2888
思路:修改Floyd,把边权和改为边权最大值。另外注意是有向图。
#include<cstdio>
#include<algorithm>
using namespace std;
#define inf 0x7fffffff
int main() {
int n,m,t;
scanf("%d%d%d",&n,&m,&t);
int d[n+][n+];
for(int i=;i<=n;i++) {
for(int j=;j<=n;j++) {
d[i][j]=(i==j)?:inf;
}
}
while(m--) {
int s,e,h;
scanf("%d%d%d",&s,&e,&h);
d[s][e]=h;
}
for(int k=;k<=n;k++) {
for(int i=;i<=n;i++) {
for(int j=;j<=n;j++) {
d[i][j]=min(d[i][j],max(d[i][k],d[k][j]));
}
}
}
while(t--) {
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",(d[a][b]!=inf)?d[a][b]:-);
}
return ;
}
[USACO07NOV]牛栏Cow Hurdles的更多相关文章
- bzoj1641 / P2888 [USACO07NOV]牛栏Cow Hurdles
P2888 [USACO07NOV]牛栏Cow Hurdles Floyd $n<=300$?果断Floyd 给出核心式,自行体会 $d[i][j]=min(d[i][j],max(d[i][k ...
- Luogu P2888 [USACO07NOV]牛栏Cow Hurdles
题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gan ...
- 洛谷 P2888 [USACO07NOV]牛栏Cow Hurdles
题目戳 题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the ...
- 洛谷P2888 [USACO07NOV]牛栏Cow Hurdles
题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gan ...
- BZOJ 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏( floyd )
直接floyd.. ---------------------------------------------------------------------------- #include<c ...
- 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏
1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 424 Solved: 272 ...
- POJ 3615 Cow Hurdles(最短路径flyod)
Cow Hurdles Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9337 Accepted: 4058 Descr ...
- OJ 21651::Cow Hurdles(佛罗一德的变式)
Description Farmer John wants the cows to prepare for the county jumping competition, so Bessie and ...
- 【poj3615】 Cow Hurdles
http://poj.org/problem?id=3615 (题目链接) 题意 给出一张有向图,求从u到v最大边最小的路径的最大边.→_→不会说话了.. Solution 好久没写Floyd了,水一 ...
随机推荐
- Jmeter 自动化测试报告扩展
首先了解下生成测试报告的过程,我们看到的测试报告是由.jtl格式转换为.html,html报告的样式由extras目录下xsl文件决定.优化测试报告需要分为两部分内容,首先我们要优化输出的测试内容,其 ...
- 开启或停止website
1.添加:Microsoft.Web.Administration 2.代码: static void Main(string[] args) { var server = new ServerMan ...
- 提取Word里的文本内容 C#
using DocumentFormat.OpenXml.Packaging; public static string TextFromWord(string path) { const strin ...
- 泛微云桥e-birdge之金蝶云之家集成配置手册
最近在配置金蝶云之家与泛微ecology的打通,没有看官方文档,直接配置,一直配置不通,看了官方文档后知道了少配置参数了,转载一下,省得四处去找了. 泛微云桥e-birdge之金蝶云之家集成配置手册 ...
- Ubuntu 16.04 卸载Postgresql
首先确保postgresql是否在运行,在命令窗口输入 netstat -nlt han@han-OptiPlex-:~/project/0_ng_practice/ng-test$ netstat ...
- bzoj2870
题解: 边分治入门题 当然并查集+维护直径更加简单 就是两棵树二合一直径是两颗树上的4个直径两两组合的最大值 查询路径长度你搞个差分查个lca就好了 点分治并不能做这题 分成多个联通块就gg了(点分治 ...
- Nginx动静分离
动静分离 Nginx动静分离是让动态网站里的动态网页根据一定规则把不变的资源和经常变的资源区分开来,动静资源做好了拆分以后,我们就可以根据静态资源的特点将其做缓存操作,这就是网站静态化处理的核心思路. ...
- python全栈开发day82-modelForm
1.jsonp内容 from django.shortcuts import render # Create your views here. def upload(request): if requ ...
- flink--DateSet开发--简单入门
开发流程 1. 获得一个execution environment, 2. 加载/创建初始数据, 3. 指定这些数据的转换, 4. 指定将计算结果放在哪里, 5. 触发程序执行 例子: object ...
- net core体系-web应用程序-1VS2017构建一个简单的web
使用vs2017,添加一个新项目-asp.net core web应用程序. 结构如图, wwwroot放了网站的静态资源如css.js.image文件: appsetting.json是应用程序的配 ...