P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…
P1360 [USACO07MAR]黄金阵容均衡Gold Balanced L… 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For ex…
题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might h…
题目 不得不说这个题非常毒瘤. 简化题意 这个题的暴力还是非常好想的,完全可以过\(50\%\)的数据.但是\(100\%\)就很难想了. 因为数据很大,所以我们需要用\(O(\sqrt n)\)的时间求出每个时间的前面第一个跟它满足均衡区间的时间. 此时我们会很快速的想到\(Hash\)或\(Map\),他们的时间复杂度是小于\(O(\sqrt n)的\)所以满足要求,因此一般看到寻找相同得值的时候,最好还是想想怎么优化吧 \(Code\) #include <iostream> #incl…
https://www.luogu.org/problem/show?pid=1360 题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For…
题目描述 Farmer John's N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different features (1 ≤ K ≤ 30). For example, cows exhibiting feature #1 might h…
传送门 真的骚的一个题,看了半天只会个前缀和+暴力.. 纯考思维.. 良心题解 #include <cstdio> #include <cstring> #include <algorithm> #define M 41 #define N 100011 #define max(x, y) ((x) > (y) ? (x) : (y)) int n, m, ans, last; struct node { int sum[M], id; node() { id =…
P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维) 前言 题目链接 本题作为一道Stl练习题来说,还是非常不错的,解决的思维比较巧妙 算是一道不错的题 思路分析 第一眼看到这题,我还以为是数据结构题,看来半天没看出来数据结构咋做(我还是太菜了) 我们对\(m\)种能力有\(n\)次操作,需要找到对每种能力提升相同的最大操作区间的长度,求最大 区间,我们考虑维护这\(m\)种技能提升值的前缀和,假设第\(l+1\)次操作到第\(r\)次操作对\(m\…
[LuoguP1360][USACP07MAR]黄金阵容均衡(Link) 每天会增加一个数\(A\),将\(A\)二进制分解为\(a[i]\),对于每一个\(i\)都增加\(a[i]\),如果一段时间之内所有的位数上的数都增加了同一个数,那么成这个天数区间为均衡的.现在要求最长的均衡区间. 这道题很显然可以使用前缀和.我们统计每一天的前缀和为一个\(map\)数组\(A\).如果区间\([L, R]\)为均衡区间,那么\(A[R] - A[L - 1]\)就一定满足每一个二进制分解的位数都相等.…
正解:AC自动机 解题报告: 传送门! 啊我好呆啊其实就挺模板题的,,,只是要一个栈搞一下,,,然后我就不会了,,,是看了题解才get的,,,QAQ 然后写下解法趴QwQ 首先看到多串匹配不难想到AC自动机?问题只是在于删了某个字符串之后怎么继续匹配下去嘛QwQ 然后我就卡这儿了QAQ 正解其实并不难想到,,,就可以开一个栈,记录一路上经过的ac自动机上的节点的编号,然后每次删了一个串之后把now跳到这个串的前一位的那个编号位置就好 补充一个恶心的小细节,,, 就是这题不输出换行会莫名其妙WA在…