P2888 [USACO07NOV]牛栏Cow Hurdles

Floyd

$n<=300$?果断Floyd

给出核心式,自行体会

$d[i][j]=min(d[i][j],max(d[i][k],d[k][j]))$

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int d[][],n,m,t;
int main(){
memset(d,,sizeof(d));
scanf("%d%d%d",&n,&m,&t);
for(int i=,q1,q2,q3;i<=m;++i){
scanf("%d%d%d",&q1,&q2,&q3);
d[q1][q2]=q3;
}
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]));
for(int i=,q1,q2;i<=t;++i){
scanf("%d%d",&q1,&q2);
if(d[q1][q2]==d[][]) printf("-1\n");
else printf("%d\n",d[q1][q2]);
}return ;
}

bzoj1641 / P2888 [USACO07NOV]牛栏Cow Hurdles的更多相关文章

  1. Luogu P2888 [USACO07NOV]牛栏Cow Hurdles

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

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

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

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

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

  4. [USACO07NOV]牛栏Cow Hurdles

    OJ题号:洛谷2888 思路:修改Floyd,把边权和改为边权最大值.另外注意是有向图. #include<cstdio> #include<algorithm> using ...

  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. bzoj1641 [Usaco2007 Nov]Cow Hurdles 奶牛跨栏

    Description Farmer John 想让她的奶牛准备郡级跳跃比赛,贝茜和她的伙伴们正在练习跨栏.她们很累,所以她们想消耗最少的能量来跨栏. 显然,对于一头奶牛跳过几个矮栏是很容易的,但是高 ...

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

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

随机推荐

  1. 1.9TF的过拟合-dropout

    不带dropout程序并通过tensorboard查看loss的图像 """ Please note, this code is only for python 3+. ...

  2. HDU 3045 - Picnic Cows - [斜率DP]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3045 It’s summer vocation now. After tedious milking, ...

  3. LDA模型数据的可视化

    """ 执行lda2vec.ipnb中的代码 模型LDA 功能:训练好后模型数据的可视化 """ from lda2vec import p ...

  4. cordova 加载HTML 资源的次序

    ionic 开发的app再启动的时候不会很快,因为cordova 会加载html,css, js这些文件,读取这些文件内的代码之后,js代码才能和Native建立桥接. 这是一个初始化运行时环境的操作 ...

  5. LDAP summary-- Python ldap

    A DN is comprised of a series of RDNs (Relative Distinguished Names) found by walking UP the tree (D ...

  6. ItunesConnect:上传完二进制文件后在构建版本中找不到

    最近经常遇到上传完二进制文件后在构建版本中找不到的情况: 环境:Xcode 8.2 (8C38) 大致有几种原因,可以按照以下步骤排查下. 排查步骤: 1.检查使用的权限,并info.plist文件中 ...

  7. 棋盘问题---poj1321(dfs)

    http://poj.org/problem?id=1321 由于搜索是原来写的,而集训的时候没来所以只能现在补补咯-_- 简单的深搜 #include<stdio.h> #include ...

  8. SQLServer DBA 三十问

    原贴:http://www.cnblogs.com/fygh/archive/2011/10/18/2216166.html 答案:https://blog.csdn.net/cjssimei527/ ...

  9. string、const char*、 char* 、char[]相互转换(待整理)

    string.const char*. char* .char[]相互转换(全) https://blog.csdn.net/rongrongyaofeiqi/article/details/5244 ...

  10. django 中的render和render_to_response()和locals()

    1. django中的render context在Django里表现为 Context 类,在 django.template 模块里. 它的构造函数带有一个可选的参数: 一个字典映射变量和它们的值 ...