CF372B Counting Rectangles is Fun

题目描述

给定一个${n * m}$的01矩阵, q次询问, 每次询问指定一个子矩形, 求该子矩形种有多少个只包含0的子矩阵. 矩阵从上到下编号1~n, 从左到右编号1~m.

输入格式

输出格式

说明/提示

For the first example, there is a $ 5×5 $ rectangular grid, and the first, the second, and the third queries are represented in the following image. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF372B/0be5a72c343f046641485221a9bc1240a20fee54.png)- For the first query, there are $ 10 $ good rectangles, five $ 1×1 $ , two $ 2×1 $ , two $ 1×2 $ , and one $ 1×3 $ . - For the second query, there is only one $ 1×1 $ good rectangle. - For the third query, there are $ 7 $ good rectangles, four $ 1×1 $ , two $ 2×1 $ , and one $ 3×1 $ .