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. kernel中文件的读写操作可以使用vfs_read()和vfs_write

    需要在Linux kernel--大多是在需要调试的驱动程序--中读写文件数据.在kernel中操作文件没有标准库可用,需要利用kernel的一些函数,这些函数主要有: filp_open() fil ...

  2. 2.1TF模型持久化

    目前tf只能保存模型中的variable变量,整个模型还不能保存,版本1.x 保存模型代码 import tensorflow as tf import numpy as np # Save to f ...

  3. Python的浅拷贝与深拷贝

    定义: =号浅拷贝:在Python中对象的赋值其实就是对象的引用.copy了之后两个仍然是同一个东西.那么他们内部的元素自然也是一样的,对其中一个进行修改,另一个也会跟着变> copy()浅拷贝 ...

  4. dbAdmin 不等于 root 集合中角色

    dbAdmin  root  集合中角色 use admin创建 db.createUser( { user: "tmp_rw_56756", pwd: "tmp4242 ...

  5. SP11469 SUBSET-Balanced Cow Subsets meet-in-the-middle+状压

    正解:折半搜索 解题报告: 传送门! 这题我开始看到的时候贼开心地就把这题的代码直接粘过来辣 然后就T辣,,,仔细思考一下,为什么呢? 因为会枚举到很多相同的状态 举个eg 20 1 1 1 1 1 ...

  6. 洛谷P2312 解方程 [noip2014] 数论

    正解:数论 解题报告: 这儿是,传送门qwq 又是很妙的一道题呢,专门用来对付我这种思维僵化了的傻逼的QAQ 首先看题目的数据范围,发现a<=1010000,很大的一个数据范围了呢,那这题肯定不 ...

  7. 聊一聊Linux中的工作队列2

    上一篇文章对工作队列原理以及核心数据结构做了简单介绍,本文重点介绍下workqueue的创建以及worker的管理. 一.工作队列的创建(__alloc_workqueue_key) struct w ...

  8. oracle行转列,列转行

    多行转字符串这个比较简单,用||或concat函数可以实现 SQL Code select concat(id,username) str from app_userselect id||userna ...

  9. 数据库级别DDL操作监控审计、数据库触发器/服务器触发器

    关键词:数据库触发器/服务器触发器  ,数据库级别DDL操作监控审计,禁止修改登录名密码 [1]数据库级别DDL操作监控审计 转自2012示例库,只能数据库级别,不能实例级别 use database ...

  10. 怎样知道 CPU 是否支持虚拟化技术(VT) | Linux 中国

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/F8qG7f9YD02Pe/article/details/79832475 wx_fmt=png&a ...