ICode9

精准搜索请尝试: 精确搜索
  • P1948 [USACO08JAN]Telephone Lines S2022-07-17 10:35:55

    [USACO08JAN]Telephone Lines S 题目描述 Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are N (1 ≤ N

  • P1948 [USACO08JAN]Telephone Lines S (分层图最短路/二分+最短路)2022-07-11 16:05:13

    题目描述 [USACO08JAN]Telephone Lines S 题目描述 Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are

  • P2899 [USACO08JAN]Cell Phone Network G2022-03-27 11:33:29

    这是一个很经典的树形dp 其实还是很有难度的 dp[u][0]表示u节点一定被自己点亮 dp[u][1]表示u节点一定被父亲点亮 dp[u][2]表示u节点一定被儿子点亮 注意这里的“一定”表示: 比如dp[u][1]表示一定u的父亲是亮的,但是不排除u是亮的或者u的儿子是亮的 尽管这里有个状态是dp[u][1]被

  • [USACO08JAN]Telephone Lines2021-05-29 19:05:07

    嘟嘟嘟   题意概括一下,就是在无向图上求一条1到n的路径,使路径上第k + 1大的边权尽量小。   考虑dp,令dp[i][j] 表示走到节点 i,路线上有 j 条电话线免费时,路径上最贵的电缆花费最小是多少。则对于一条从u到v,长度为w的边,转移方程是:     1.这条电缆要付费:dp[v][p] = min(dp[v][p

  • P2419 [USACO08JAN]Cow Contest S2021-04-17 17:03:27

    传递闭包裸题。 如果一头奶牛和其他\(n-1\)头奶牛的大小关系都确定了,那么该奶牛的排名可唯一确定。 或者说,比它强的奶牛的数量加上比它弱的奶牛的数量等于\(n-1\),就可唯一确定该奶牛的名次。 const int N=110; bool g[N][N]; int n,m; void floyd() { for(int k=1;k<=n;k++)

  • luogu P2419 [USACO08JAN]牛大赛Cow Contest2019-11-14 22:03:26

    题目描述 N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors. The contest is condu

  • luogu P2899 [USACO08JAN]手机网络Cell Phone Network |贪心2019-11-13 21:59:00

    include include include include include include define db double using namespace std; const int N=1e5+10,M=2*N; int next[M],head[N],go[M],tot; inline void add(int u,int v){ next[++tot]=head[u];head[u]=tot;go[tot]=v; next[++tot]=head[v];head[v]=tot;go[tot]

  • P1948 [USACO08JAN]电话线Telephone Lines2019-09-15 18:56:43

    题目链接   P1948 [USACO08JAN]电话线Telephone Lines 分析 简单观察题目,易得本题是求解最小最大值,宜用二分!!! 证明:当存在一种有效路径时,这种路径会包含一种更小代价的有效路径(即可能是存在更小的最大值) 二分思路:在(l,r)区间内寻找符合条件的最大值,l=0,r=最大边权值 具体判断: 将

  • 洛谷P1948 [USACO08JAN]电话线Telephone Lines2019-06-05 19:41:48

    链接: https://www.luogu.org/problemnew/show/P1948 bfs+剪枝即可 代码: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> using namespace std; struct edge { int to,dis,next; }; struct node {

  • P1948 [USACO08JAN]电话线Telephone Lines2019-06-02 09:42:40

    ------------------------------ 这道题就是我们的sb比赛第四题 ----------------------------- 这道题吧,还是很有意思的,需要用到二分,不过用bfs也行(暴力出奇迹) ------------------------------ 并且深刻让我感受到了做题时,重构代码的恶心 有时候就是写错了一个字母,但是怎么找还找不

  • P2419 [USACO08JAN]牛大赛Cow Contest(dfs走天下/)2019-04-14 15:48:53

    题目描述 FJ的N(1 <= N <= 100)头奶牛们最近参加了场程序设计竞赛:)。在赛场上,奶牛们按1..N依次编号。每头奶牛的编程能力不尽相同,并且没有哪两头奶牛的水平不相上下,也就是说,奶牛们的编程能力有明确的排名。 整个比赛被分成了若干轮,每一轮是两头指定编号的奶牛的对决。如果编号为A

  • [USACO08JAN]牛大赛Cow Contest2019-04-13 22:42:14

    题目大意:有若干个数(各不相同),给出若干个大小关系,问有多少个数大小关系确定? n<=100 m<=4500 真是一道好题啊。。。 直接说思路吧,这道题利用了图的思想: 我们把a大于b看作从a向b连一条有向边,那么两个数如果大小关系确定的话就代表两点是联通的,那么我们就可以利用floyd的思想: 如果i能到j,只有两种可能:从i到j有

  • P2419 [USACO08JAN]牛大赛Cow Contest2019-04-12 20:40:41

      Floyd不仅能求出最短路,还能利用或运算,与运算判断两点是否连通。   小范围数据,Floyd经常是很好的思路!   代码!    #include<cstdio>#include<iostream>#include<cstring>using namespace std;#define maxn 200int f[maxn][maxn];int n,m;int main(){ scanf("%d%d",&n,&

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有