题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and returns. She is curious as to just how mu…
https://www.luogu.org/problem/show?pid=2957 题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out a…
传送门 团队里的hash水题,数据小的不用hash都能过.. 也就是前缀hash,后缀hash,再比较一下就行. ——代码 #include <cstdio> #include <cstring> #define ULL unsigned long long int n, m, ans; ], s2[]; ULL ], sum1[], sum2[], bit1[], bit2[]; inline int max(int x, int y) { return x > y ? x…
https://www.luogu.org/problem/P2957 题目描述 The cows enjoy mooing at the barn because their moos echo back, although sometimes not completely. Bessie, ever the excellent secretary, has been recording the exact wording of the moo as it goes out and retur…
P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer's land. He raises delicious papaya fruit, which is a delicacy for cows. The papaya jungle is partitioned into a grid of squares with R rows and C col…
P2958 [USACO09OCT]木瓜的丛林Papaya Jungle 题目描述 Bessie has wandered off the farm into the adjoining farmer's land. He raises delicious papaya fruit, which is a delicacy for cows. The papaya jungle is partitioned into a grid of squares with R rows and C col…
P2376 [USACO09OCT]津贴Allowance 题目描述 作为创造产奶纪录的回报,\(Farmer\) \(John\)决定开始每个星期给\(Bessie\)一点零花钱. \(FJ\)有一些硬币,一共有\(N(1<=N<=20)\)种不同的面额.每一个面额都能整除所有比它大的面额. 他想用给定的硬币的集合,每个星期至少给\(Bessie\)某个零花钱的数目\(C(1<=C<=100000000)\).请帮他计算他最多能支付多少个星期的零花钱. 输入输出格式 输入格式:…
P1339 [USACO09OCT]热浪Heat Wave 题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to delive…
P2959 [USACO09OCT]悠闲漫步The Leisurely Stroll 题目描述 Bessie looks out the barn door at the beautiful spring day and thinks to herself, 'I'd really like to enjoy my walk out to the pastures for the tender spring grass.' She knows that once she leaves the b…
P2960 [USACO09OCT]Milkweed的入侵Invasion of the Milkweed 题目描述 Farmer John has always done his best to keep the pastures full of luscious, delicious healthy grass for the cows. He has lost the battle, though, as the evil milkweed has attained a foothold…
题目传送门 这道题实际非常简单好奇是怎么变黄的... 其实也就是一个SPFA,本人非常懒,不想打邻接表,直接用矩阵就好啦... #include<bits/stdc++.h> using namespace std; ][],m,fr,to; void add(int x,int y,int z){a[x][y]=z;} ]; ]; queue<int> q; void SPFA(int from){ vis[; q.push(; while(!q.empty()){ ; q.po…
题目传送门 这也是个01背包,只是装的很... #include<bits/stdc++.h> #define MAXN 45010 using namespace std; int f[MAXN],w[MAXN],c[MAXN],n,v; int main(){ scanf("%d%d",&v,&n); ;i<=n;i++) scanf("%d",&w[i]); ;i<=n;i++) for(int j=v;j>…
题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更多的干草.很自然地,每捆干草只能被吃一次(即使在列表中相同的重量可能出现2次,但是这表示…
https://www.luogu.org/problemnew/show/P2376 看了题解做的,根本不会贪心.. #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back t…
题目链接:https://www.luogu.org/problemnew/show/P1339 解题思路: 一道简单的最短路水题,dijkstra解法模板思路:https://www.cnblogs.com/lipeiyi520/p/10340361.html AC代码: #include<bits/stdc++.h> using namespace std; const int ff=0x3f3f3f; ][],a,b,c; ]; ]; void dij(int s){ memset(vi…
题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to deliver plenty of ice cold nutritiou…
[题解] 最短路.那么直接写dijkstra就好了. #include<cstdio> #include<algorithm> #include<cstring> #define LL long long #define rg register #define N 200010 using namespace std; int n,m,s,t,tot,last[N],dis[N],pos[N]; struct edge{ int to,pre,dis; }e[N<…
https://www.luogu.org/problem/show?pid=2639 题目描述 Bessie像她的诸多姊妹一样,因为从Farmer John的草地吃了太多美味的草而长出了太多的赘肉.所以FJ将她置于一个及其严格的节食计划之中.她每天不能吃多过H (5 <= H <= 45,000)公斤的干草. Bessie只能吃一整捆干草:当她开始吃一捆干草的之后就再也停不下来了.她有一个完整的N (1 <= N <= 500)捆可以给她当作晚餐的干草的清单.她自然想要尽量吃到更…
思路:裸SPFA过一遍(建议使用邻接链表存储),无向图,无向图,无向图,重要的事情要说三遍!!!蜜汁RE是什么鬼????第九个点数组开到20K,第十个点数组开到30K才AC.或许我代码写的有bug?(逃 CODE: #include<iostream> #include<queue> using namespace std; queue<int>q; struct Edge{ int pre,to,w; }edge[]; ]; ]; ]; int T, C, Ts, T…
题目描述 The good folks in Texas are having a heatwave this summer. Their Texas Longhorn cows make for good eating but are not so adept at creating creamy delicious dairy products. Farmer John is leading the charge to deliver plenty of ice cold nutritiou…
题目链接 https://www.luogu.org/problemnew/show/P1339 最短路 解题思路 dijkstra直接过 注意: 双向边 memset ma数组要在读入之前 AC代码 #include<iostream> #include<cstring> using namespace std; int n,m,ts,te; ]; ]; ][]; int main(){ cin>>n>>m>>ts>>te; mem…
题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive integers I (1 <= I <= 10^60) for which Bessie must determine their parity (explained in second grade as 'Even... or odd?'). Bessie is overwhelmed by the…
嗯... 题目链接:https://www.luogu.org/problem/P1339 这道题是水的不能在水的裸最短路问题...这里用的dijkstra 但是自己进了一个坑—— 因为有些城市之间可能还没有道路,自己只是将其初始化为0,而应该初始化为0x3f3f,从而表示两个城市之间没有道路... AC代码: #include<cstdio> #include<iostream> #include<algorithm> #include<cstring>…
题目描述 平面上有 \(n\) 个点,第 \(i\) 个点坐标为 \((x_i, y_i)\).连接 \(i, j\) 两点的边权为 \(\sqrt{(x_i - x_j) ^ 2 + (y_i - y_j) ^ 2}\).求最小生成树的边权之和. 输入格式 第一行一个整数 \(n\). 接下来 \(n\) 行,每行输入两个整数 \(x_i, y_i\)​. 输出格式 输出一行一个实数,表示答案. 当你的答案与标准输出的绝对误差或相对误差在 \(10^{-6}\) 内时,就会被视为正确. 输入输…
AC代码 #include<bits/stdc++.h> using namespace std; const int MAXN=62000+10,INF=999999; struct Edge{ int u,v,w,next; }edge[MAXN]; int head[MAXN],n,m,s,t,dist[MAXN],cnt; bool vis[MAXN]; void addedge(int x,int y,int z){ edge[cnt].u=x; edge[cnt].v=y; edg…
题目背景 (USACO 5.3.4) 题目描述 农夫约翰想要在他的正方形农场上建造一座正方形大牛棚.他讨厌在他的农场中砍树,想找一个能够让他在空旷无树的地方修建牛棚的地方.我们假定,他的农场划分成 N x N 的方格.输入数据中包括有树的方格的列表.你的任务是计算并输出,在他的农场中,不需要砍树却能够修建的最大正方形牛棚.牛棚的边必须和水平轴或者垂直轴平行. EXAMPLE 考虑下面的方格,它表示农夫约翰的农场,‘.'表示没有树的方格,‘#'表示有树的方格 1 2 3 4 5 6 7 8 1 .…
P1724 东风谷早苗 题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走,厉害吧(好吧,我自重).早苗的新模型可以按照输入的命令进行移动,命令包含’E’.’S’.’W’.’N’四种,分别对应四个不同的方向,依次为东.南.西.北.执行某个命令时,它会向着对应方向移动一个单位.作为新型机器人,自然不会只单单执行一个命令,它可以执行命令串.对于输入的命令串,每一秒它会按照命令行动一次…
题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走,厉害吧(好吧,我自重).早苗的新模型可以按照输入的命令进行移动,命令包含’E’.’S’.’W’.’N’四种,分别对应四个不同的方向,依次为东.南.西.北.执行某个命令时,它会向着对应方向移动一个单位.作为新型机器人,自然不会只单单执行一个命令,它可以执行命令串.对于输入的命令串,每一秒它会按照命令行动一次.而执行完命令串最后一个…
P1724 东风谷早苗 题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走,厉害吧(好吧,我自重).早苗的新模型可以按照输入的命令进行移动,命令包含’E’.’S’.’W’.’N’四种,分别对应四个不同的方向,依次为东.南.西.北.执行某个命令时,它会向着对应方向移动一个单位.作为新型机器人,自然不会只单单执行一个命令,它可以执行命令串.对于输入的命令串,每一秒它会按照命令行动一次…
题目传送门 题目描述 After scrimping and saving for years, Farmer John has decided to build a new barn. He wants the barn to be highly accessible, and he knows the coordinates of the grazing spots of all N (2 ≤ N ≤ 10,000 cows. Each grazing spot is at a point…