二维差分与前缀和
“最难原谅的人往往就是你自己。”
二维前缀和
几何意义:以
二维差分
差分的前缀和是原来的单点值,即
现在想推出差分数组等于什么
要给二维平面上的一个矩形区域 +1
,转换成单点的加减。即要给左上角为 (xl, yl)
,右下角为 (xr, yr)
的矩形范围里的点 +1
(包括边界),转换成下面的四个单点变化:
1 | d[xl][yl]++; d[xr + 1][yr + 1]++; |
例题
https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/5/DSL_5_B
The Maximum Number of Overlaps
Given a set of
Input
The input is given in the following format.
Constraints
are given in integers
Output
Print the maximum number of overlapped seals in a line.
因为是求面积重合的最大值,就把每个矩形记到右下角上。即左上角要往右下移动一格。
1 |
|
- Post title:二维差分与前缀和
- Post author:Eva.Q
- Create time:2022-08-20 10:06:28
- Post link:https://qyy/2022/08/20/Algorithm/二维差分与前缀和/
- Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.