题目 不得不说这个题非常毒瘤. 简化题意 这个题的暴力还是非常好想的,完全可以过\(50\%\)的数据.但是\(100\%\)就很难想了. 因为数据很大,所以我们需要用\(O(\sqrt n)\)的时间求出每个时间的前面第一个跟它满足均衡区间的时间. 此时我们会很快速的想到\(Hash\)或\(Map\),他们的时间复杂度是小于\(O(\sqrt n)的\)所以满足要求,因此一般看到寻找相同得值的时候,最好还是想想怎么优化吧 \(Code\) #include <iostream> #incl…
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…
P1360 [USACO07MAR]Gold Balanced Lineup G (前缀和+思维) 前言 题目链接 本题作为一道Stl练习题来说,还是非常不错的,解决的思维比较巧妙 算是一道不错的题 思路分析 第一眼看到这题,我还以为是数据结构题,看来半天没看出来数据结构咋做(我还是太菜了) 我们对\(m\)种能力有\(n\)次操作,需要找到对每种能力提升相同的最大操作区间的长度,求最大 区间,我们考虑维护这\(m\)种技能提升值的前缀和,假设第\(l+1\)次操作到第\(r\)次操作对\(m\…
题目描述 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…
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 =…
洛谷P1854 花店橱窗布置 分析+题解代码 蒟蒻的第一道提高+/省选-,纪念一下. 题目描述: 某花店现有F束花,每一束花的品种都不一样,同时至少有同样数量的花瓶,被按顺序摆成一行,花瓶的位置是固定的,从左到右按1到V顺序编号,V是花瓶的数目.花束可以移动,并且每束花用1到F的整数标识.如果I < J,则花束I必须放在花束J左边的花瓶中.例如,假设杜鹃花的标识数为1,秋海棠的标识数为2,康乃馨的标识数为3,所有花束在放入花瓶时必须保持其标识数的顺序,即杜鹃花必须放在秋海棠左边的花瓶中,秋海棠必…
[LuoguP1360][USACP07MAR]黄金阵容均衡(Link) 每天会增加一个数\(A\),将\(A\)二进制分解为\(a[i]\),对于每一个\(i\)都增加\(a[i]\),如果一段时间之内所有的位数上的数都增加了同一个数,那么成这个天数区间为均衡的.现在要求最长的均衡区间. 这道题很显然可以使用前缀和.我们统计每一天的前缀和为一个\(map\)数组\(A\).如果区间\([L, R]\)为均衡区间,那么\(A[R] - A[L - 1]\)就一定满足每一个二进制分解的位数都相等.…