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. 【第一部分】07Leetcode刷题

    二.寻找旋转排序数组中的最小值 题目:153. Find Minimum in Rotated Sorted Array C++ Soution 1: class Solution { public: ...

  2. vi不保存退出

    To quit the vi editor without saving any changes you've made If you are currently in insert or appen ...

  3. 实战--Keepalived和LVS实现负载高可用

    显然,只有上一篇的操作,在WEB运维技术中,只能承担一半的角色. 想像一下,如何LVS本身倒了,肿么办?后端的NGINX再多,也只能是干着急,请求过来不呀! 所以,在本篇时,我们来实现LVS永不倒, ...

  4. SSO单点登录原理

    一.单系统登录机制 1.http无状态协议 web应用采用browser/server架构,http作为通信协议.http是无状态协议,浏览器的每一次请求,服务器会独立处理,不与之前或之后的请求产生关 ...

  5. openpose pytorch代码分析

    github: https://github.com/tensorboy/pytorch_Realtime_Multi-Person_Pose_Estimation # -*- coding: utf ...

  6. Codeforces Round #506 (Div. 3)

    题解: div3水的没有什么意思 abc就不说了 d题比较显然的就是用hash 但是不能直接搞 所以我们要枚举他后面那个数的位数 然后用map判断就可以了 刚开始没搞清楚数据范围写了快速乘竟然被hac ...

  7. 【转载】Python and Mysql Andy Dustman

    0. http://mysql-python.sourceforge.net/ Python and MySQL: This is a presentation I did a couple year ...

  8. Dapper Helper

    using System; using System.Collections.Generic; using System.Configuration; using System.Data; using ...

  9. tomcat配置后台管理监控页面

  10. Python学习(六) —— 函数

    一.函数的定义和调用 为什么要用函数:例如,计算一个数据的长度,可以用一段代码实现,每次需要计算数据的长度都可以用这段代码,如果是一段代码,可读性差,重复代码多: 但是如果把这段代码封装成一个函数,用 ...