题目描述 After several months of rehearsal, the cows are just about ready to put on their annual dance performance; this year they are performing the famous bovine ballet "Cowpelia". The only aspect of the show that remains to be determined is the s…
https://www.luogu.org/problemnew/show/P3611 二分答案+优先队列 二分O(logn) 判一次正确性O(nlogn) 总体O(nlognlogn) 为了让priority_queue变成小根堆,就把元素全部取相反数了. #include<iostream> #include<cstdio> #include<queue> using namespace std; inline int rd(){ ,f=;char c; :; +c…
想了一下还是不发以前做过的水题了,意义也不是很大,现在的话大概只有洛谷黄题以上才会收录了哦~~~ 喵了个咪的题面~~ 洛谷题解dalao不是P党就是优先队列,看的我作为一个新手蒟蒻好慌啊... 这题用二分加冒泡(你没有看错,用sort反而会超时) 先用二分决定k的值,然后判断这个k可不可行,然后继续二分,重复刚才操作 具体解释看代码: #include<cmath> #include<cstdio> #include<iostream> #include<cstr…
题目链接 Bzoj崩了之后在洛谷偶然找到的点分好题! 在暴力的角度来说,如果我们$O(n)$枚举根节点,有没有办法在$O(n)$的时间内找到答案呢? 此时如果用树形$dp$的想法,发现是可做的,因为可以推得以下的结论: 设$x$为根节点,$d[i]$为$i$节点到$x$的距离(即深度),$g[i]$为$i$节点到最近的出入口(即叶子节点)的距离,$ans_{x}$为以$x$为根节点时的答案. 如果$d[i] \geq g[i]$,则我们可以确定,以$i$为子树,对于$x$为根时的答案贡献为$1$…
洛谷题面传送门 点分治 hot tea. 首先考虑什么样的点能够对以 \(u\) 为根的答案产生 \(1\) 的贡献.我们考虑以 \(u\) 为根对整棵树进行一遍 DFS.那么对于一个点 \(v\),我们记其 \(mn_v\) 为其子树内距离其最近的叶子,\(dep_v\) 为 \(u\) 到 \(v\) 的距离,那么如果 \(mn_v\ge dep_v\),那么对于任何一个 \(v\) 子树内的叶子 \(w\),如果 Bessie 选择从 \(w\) 逃出且我们在距离 \(v\) 最近的叶子处…
P3608 [USACO17JAN]Balanced Photo平衡的照片 题目描述 Farmer John is arranging his NN cows in a line to take a photo (1 \leq N \leq 100,0001≤N≤100,000). The height of the iith cow in sequence is h_ih​i​​, and the heights of all cows are distinct. As with all ph…
题目传送门 Promotion Counting 题目描述 The cows have once again tried to form a startup company, failing to remember from past experience that cows make terrible managers! The cows, conveniently numbered 1 \ldots N1…N (1 \leq N \leq 100,0001≤N≤100,000), organ…
题目传送门 摩天大楼里的奶牛 题目描述 A little known fact about Bessie and friends is that they love stair climbing races. A better known fact is that cows really don't like going down stairs. So after the cows finish racing to the top of their favorite skyscraper, th…
题目描述 Just like humans enjoy playing the game of Hopscotch, Farmer John&apos;s cows have invented a variant of the game for themselves to play. Being played by clumsy animals weighing nearly a ton, Cow Hopscotch almost always ends in disaster, but thi…
P3052 [USACO12MAR]摩天大楼里的奶牛Cows in a Skyscraper 题目描述 A little known fact about Bessie and friends is that they love stair climbing races. A better known fact is that cows really don't like going down stairs. So after the cows finish racing to the top…