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的更多相关文章

  1. bzoj1641 / P2888 [USACO07NOV]牛栏Cow Hurdles

    P2888 [USACO07NOV]牛栏Cow Hurdles Floyd $n<=300$?果断Floyd 给出核心式,自行体会 $d[i][j]=min(d[i][j],max(d[i][k ...

  2. Luogu P2888 [USACO07NOV]牛栏Cow Hurdles

    题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gan ...

  3. 洛谷 P2888 [USACO07NOV]牛栏Cow Hurdles

    题目戳 题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the ...

  4. 洛谷P2888 [USACO07NOV]牛栏Cow Hurdles

    题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gan ...

  5. BZOJ 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏( floyd )

    直接floyd.. ---------------------------------------------------------------------------- #include<c ...

  6. 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏

    1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 424  Solved: 272 ...

  7. POJ 3615 Cow Hurdles(最短路径flyod)

    Cow Hurdles Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9337   Accepted: 4058 Descr ...

  8. OJ 21651::Cow Hurdles(佛罗一德的变式)

    Description Farmer John wants the cows to prepare for the county jumping competition, so Bessie and ...

  9. 【poj3615】 Cow Hurdles

    http://poj.org/problem?id=3615 (题目链接) 题意 给出一张有向图,求从u到v最大边最小的路径的最大边.→_→不会说话了.. Solution 好久没写Floyd了,水一 ...

随机推荐

  1. 论文阅读笔记十五:Pyramid Scene Parsing Network(CVPR2016)

    论文源址:https://arxiv.org/pdf/1612.01105.pdf tensorflow代码:https://github.com/hellochick/PSPNet-tensorfl ...

  2. Two Sum【LeetCode】

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  3. 集腋成裘-03-css基础-02

    1.1 三种写法 内嵌式:样式只作用于当前文件,没有真正实现结构表现分离 外链式:作用范围是当前站点,真正实现了内容与表现分离 行内样式:仅限于当前标签,结构混在一起 1.2 标签分类 1.2.1 块 ...

  4. 点击图片弹出input type=file选择器

    <label for="UploadCoverPhoto" class="cursor-pointer"> <img class=" ...

  5. gradle repo conf - maven-central.storage-download.googleapis.com

    repositories { google() jcenter() maven { // The google mirror is less flaky than mavenCentral() url ...

  6. Ubuntu安装TensorFlow

    使用清华大学开源软件镜像站:https://mirrors.tuna.tsinghua.edu.cn/ 下载. 在主界面右侧找到[相关链接]->[使用帮助],然后在出现的页面左侧找到Tensor ...

  7. .net core vs2015 vs2017打开后errpr

    需要将每个项目中增加global.json  并设置sdk的版本,注意,每个类库中均需增加. { "sdk": { "version": "1.0.0 ...

  8. centos 6.5升级内核到3.1

    1.查看本机内核版本 [root@localhost ~]# uname -r 2.6.32-358.el6.x86_64 2.安装含有内核软件的源 步骤一:导入证书 [root@localhost ...

  9. Vue爬坑之路

    1.关闭eslint严格语法检查

  10. Vue全局API总结

    1.extend用于创建一个子类Vue,用$mount来挂载 <body> <div id="app"></div> <script> ...