[Agc081F/At2699] 给出一个拥有 \(H\times W\) 个格子的棋盘,每个格子的颜色为黑色或白色. Snuke 可以进行任意次下列操作: 选择棋盘中的一行或一列,将这一行或一列的颜色翻转(黑变成白,白变成黑) Snuke 想知道,在他进行操作后,棋盘中最大的全黑矩形最大能为多少. 考虑 \(2\times 2\) 方格,当且仅当偶数个黑时,可以做成全黑 大矩形能做成全黑,当且仅当所有 \(2\times 2\) 子格都是偶数个黑 然后就是一个很朴素的单调栈求最大矩形了 注意到…
题目大意:有一个$n\times m$的$01$矩阵,可以把任意行或列反转,问最大的全为一的子矩阵的面积 题解:有一个结论:若一个子矩形$S$中的任意一个$2\times 2$的子矩形都含有偶数个$1$,则存在一种操作使得$S$中全为$1$. 就令四个点亦或值为$0$的格子(有偶数个$1$)的左上角权值为$1$,求一个最大全$1$子矩形就好了.可以拿单调栈来做 卡点:1.意外交了$python$然后显示$RE$,然后就莫名调了好久 2.$ans$的初值未赋:$ans=max(n,m)$,因为有可…
Given an R×C grid with each cell containing an integer, find the number of subrectangles in this grid that contain only one distinct integer; this means every cell in a subrectangle contains the same integer. A subrectangle is defined by two cells: t…
以下是简要题解: 首先思考如何判定一个矩形是否能通过操作变成全黑. 首先从简单而又特殊的 \(2 \times 2\) 的矩形开始,不难发现只要其中黑色数量不为奇数即可. 近一步拓展可以发现,一个矩形合法当且仅当所有 \(2 \times 2\) 的矩形均满足黑色数量不为奇数. 充分性显然,必要性证明思路如下:显然通过任意的操作不会改变 \(2 \times 2\) 子矩形黑色数量为偶数个的性质,通过构造一定能使得第一行第一列一定为黑色,那么根据一个矩形内部黑色数量不为奇数,必定可以推出矩形全黑…
[Arc081F]Flip and Rectangles 试题分析 首先考虑如何操作,发现我们只会选若干行和若干列来进行一次取反. 这个东西相当于什么呢?相当于交点不变,然后这些行和这些列的其它点取反. 那么也就是说,当一行的一段和上一行的一段互补或者相等的时候它们是一定能被搞成全黑矩形的. 然后基于这个结论,我就写了一个\(O(n^2\log n)\)的做法,然后完美地被卡了\(1.5\)的常数?! 当然,我们还可以继续考虑一下,发现做两遍差分以后这个问题会变得简单,枚举左端点,然后右端点求出…
最后更新于2019.1.23 A Famous City ?戳这里可以前往原题 Problem Description After Mr. B arrived in Warsaw, he was shocked by the skyscrapers and took several photos. But now when he looks at these photos, he finds in surprise that he isn't able to point out even the…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19782   Accepted: 6393 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…
传送门 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rec…
http://poj.org/problem?id=2559 Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12297   Accepted: 3974 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base lin…
Largest Rectangle in a Histogram Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15831   Accepted: 5121 Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal wi…