P3456 [POI2007]GRZ-Ridges and Valleys 题意翻译 给定一个地图,为小朋友想要旅行的区域,地图被分为n*n的网格,每个格子(i,j) 的高度w(i,j)是给定的.若两个格子有公共顶点,那么他们就是相邻的格子.(所以与(i,j)相邻的格子有(i-1, j-1),(i-1,j),(i-1,j+1),(i,j-1),(i,j+1),(i+1,j-1),(i+1,j),(i+1,j+1)).我们定义一个格子的集合S为山峰(山谷)当且仅当: 1.S的所有格子都有相同的高度…
洛谷题目链接:[POI2007]TET-Tetris Attack 题目描述 A puzzle called "Tetris Attack" has lately become a very popular game in Byteotia. The game itself is highlysophisticated, so we shall only introduce its simplified rules: the player is given a stack of \(2…
洛谷题目链接:[POI2007]POW-The Flood 题意翻译 Description 你手头有一张该市的地图.这张地图是边长为 m∗n 的矩形,被划分为m∗n个1∗1的小正方形.对于每个小正方形,地图上已经标注了它的海拔高度以及它是否是该市的一个组成部分.地图上的所有部分都被水淹没了.并且,由于这张地图描绘的地面周围都被高山所环绕,洪水不可能自动向外排出.显然,我们没有必要抽干那些非该市的区域. 每个巨型抽水机可以被放在任何一个1∗1正方形上.这些巨型抽水机将持续地抽水直到这个正方形区域…
洛谷题目传送门 正解是树状数组维护dfn序上的前缀和,这样的思路真是又玄学又令我惊叹( 我太弱啦,根本想不到)Orz各路Dalao 今天考了这道题,数据范围还比洛谷的小,只有\(10^5\)(害我复制粘贴一波交上去RE),让我很放心地去想树剖了. 然而尴尬的是我不会树剖,却先学了LCT(再次暴露蒟蒻的本性) 树剖的模型是,把土路视为权值,有修改,然后要查询某节点到根节点的权值和.没有换根的话,边权直接视为点权. 然后我干脆直接用Splay维护链剖分算啦(其实就是弱化板的LCT,有点像我弹飞绵羊的…
题目传送门 MEG 题目描述 Byteotia has been eventually touched by globalisation, and so has Byteasar the Postman, who once roamedthe country lanes amidst sleepy hamlets and who now dashes down the motorways. But it is those strolls inthe days of yore that he re…
题面: https://www.luogu.org/problemnew/show/P3462 https://www.lydsy.com/JudgeOnline/problem.php?id=1110 https://szkopul.edu.pl/problemset/problem/y7tXjqVq0gPZjc8kPrscs2CJ/site/?key=statement 先打了个贪心.直接所有容器从大到小排序,按这个顺序处理容器,每个容器每次装能够装进且最大的砝码.用multiset维护.…
题面 考虑 \(\text{Flood Fill}\). 每次在 \(\text{BFS}\) 扩展的过程中增加几个判断条件,记录山峰和山谷的个数即可. #include <bits/stdc++.h> using namespace std; int n, m, w[1003][1003], c1, c2; bool st[1003][1003]; pair <int, int> q[1001 * 1001]; int hh, tt; inline void bfs(int x,…
题目链接:P3455 [POI2007]ZAP-Queries 题意 给定 \(a,b,d\),求 \(\sum_{x=1}^{a} \sum_{y=1}^{b}[gcd(x, y) = d]\). 思路 莫比乌斯函数的一个性质: \[[x = 1] = \sum_{d|x} \mu(d)\] 设 \(a \le b\),对原式转化: \[\sum_{x=1}^{a} \sum_{y=1}^{b}[gcd(x, y) = d] \\ = \sum_{x=1}^{\lfloor \frac{a}{…
[POI2007]MEG-Megalopolis 题目描述 Byteotia has been eventually touched by globalisation, and so has Byteasar the Postman, who once roamedthe country lanes amidst sleepy hamlets and who now dashes down the motorways. But it is those strolls inthe days of…
题目描述 Byteasar the Cryptographer works on breaking the code of BSA (Byteotian Security Agency). He has alreadyfound out that whilst deciphering a message he will have to answer multiple queries of the form"for givenintegers aa , bb and dd , find the n…