[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了,水一 ...
随机推荐
- 论文阅读笔记十五:Pyramid Scene Parsing Network(CVPR2016)
论文源址:https://arxiv.org/pdf/1612.01105.pdf tensorflow代码:https://github.com/hellochick/PSPNet-tensorfl ...
- Two Sum【LeetCode】
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
- 集腋成裘-03-css基础-02
1.1 三种写法 内嵌式:样式只作用于当前文件,没有真正实现结构表现分离 外链式:作用范围是当前站点,真正实现了内容与表现分离 行内样式:仅限于当前标签,结构混在一起 1.2 标签分类 1.2.1 块 ...
- 点击图片弹出input type=file选择器
<label for="UploadCoverPhoto" class="cursor-pointer"> <img class=" ...
- gradle repo conf - maven-central.storage-download.googleapis.com
repositories { google() jcenter() maven { // The google mirror is less flaky than mavenCentral() url ...
- Ubuntu安装TensorFlow
使用清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/ 下载. 在主界面右侧找到[相关链接]->[使用帮助],然后在出现的页面左侧找到Tensor ...
- .net core vs2015 vs2017打开后errpr
需要将每个项目中增加global.json 并设置sdk的版本,注意,每个类库中均需增加. { "sdk": { "version": "1.0.0 ...
- centos 6.5升级内核到3.1
1.查看本机内核版本 [root@localhost ~]# uname -r 2.6.32-358.el6.x86_64 2.安装含有内核软件的源 步骤一:导入证书 [root@localhost ...
- Vue爬坑之路
1.关闭eslint严格语法检查
- Vue全局API总结
1.extend用于创建一个子类Vue,用$mount来挂载 <body> <div id="app"></div> <script> ...