[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了,水一 ...
随机推荐
- springboot集成druid+mybatis连接oracle数据库
2.1.配置 druid 数据源 2. 随后要进行druid 的数据源的配置,如果要想使用druid 的数据源,那么首先一定要去修改 pom.xml 配置文件,引入以下包: oracle官网下载 oj ...
- hdfs数据到hbase过程
需求:将HDFS上的文件中的数据导入到hbase中 实现上面的需求也有两种办法,一种是自定义mr,一种是使用hbase提供好的import工具 一.hdfs中的数据是这样的 hbase创建好表 cre ...
- 五.hadoop 从mysql中读取数据写到hdfs
目录: 目录见文章1 本文是基于windows下来操作,linux下,mysql-connector-java-5.1.46.jar包的放置有讲究. mr程序 import java.io.DataI ...
- models批量生成数据
models批量生成数据 1.将数据生成为 列表序列,通过 bulk_create 将数据一次插入数据库中 def host(request): # 插入数据速度快消耗资源少 Hostlist=[] ...
- jquery实现全选 反选 取消
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- scrollReveal.js – 页面滚动显示动画JS
简介 和 WOW.js 一样,scrollReveal.js 也是一款页面滚动显示动画的 JavaScript ,能让页面更加有趣,更吸引用户眼球.不同的是 WOW.js 的动画只播放一次,而 ...
- QQ登录用到的URL
//QQ 登陆页面的URL,client_id就是APP ID,会返回一个codehttps://graph.qq.com/oauth2.0/authorize?response_type=code& ...
- 【转】Windows Server 2008 R2下安装 .net framework3.5
原文地址:http://hi.baidu.com/tonny_dxf/item/6831bcdc3d7c06e7b2f7777c [你必须用角色管理工具安装.net framework3.5 ...
- net core体系-web应用程序-4net core2.0大白话带你入门-8asp.net core 内置DI容器(DependencyInjection,控制翻转)的一点小理解
asp.net core 内置DI容器的一点小理解 DI容器本质上是一个工厂,负责提供向它请求的类型的实例. .net core内置了一个轻量级的DI容器,方便开发人员面向接口编程和依赖倒置(IO ...
- RBM:深度学习之Restricted Boltzmann Machine的BRBM学习+LR分类—Jason niu
from __future__ import print_function print(__doc__) import numpy as np import matplotlib.pyplot as ...