当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2843:Cutting Cake

题目描述
Today, Fish gives QQ a cake for her birthday. The cake is unusual, and it looks like a square. The cake is made up of cream cells. The number of the cells is N * N. At first every cell is connected with 4 cells that are next to it.

Now, QQ wants to cut the cake. She has a special way to cut the cake. Every time, she will cut a rectangle from the cake. After this cut, the cells in the rectangle will be taken away. You know that some cells are connected as a piece of cake. Now Fish think it's a time to show how clever he is. As QQ's boy friend, he knows the size of the rectangle and where QQ will cut it each time. But it's a difficult job to calculate the number of the pieces QQ and Fish can take away after every cut. So Fish asks your help. As Fish's best friend, can you help the poor boy – Fish?

Take the following figure for example. In the figure, the grey cells have been taken away, while other cells are still in the cake. After this cut, which is drawn in the red rectangle, 4 pieces of cake will be taken away, which are the green one, the purple one, the yellow one and the blue one.
输入解释
The input consists of a single test case. The first line of input contains two positive integers N and M (1 <= N <= 1000, 1 <= M <= 10000), which are the size of cake and the numbers of cuts. The following M lines, each contains 4 integers x1, y1, x2, y2 (1 <= x1 <= x2 <= N, 1 <= y1 <= y2 <= N), which are the coordinates of the top left cell and bottom right cell. The M rectangles are given in order.
输出解释
The output consists of m lines. Each line contains an integer, which is the number of the pieces QQ and Fish may take away after this cut.
输入样例
sample input#1
3 2
1 2 3 2
2 1 2 3
sample input#2
3 5
1 2 1 2
2 2 2 2
2 1 2 1
3 3 3 3
1 1 3 3
输出样例
sample output#1
1
2
sample output#2
1
1
1
1
3
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 3000MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2843

最后修改于 2020-10-29T06:45:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000 131072