QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 110

#13367. 灯泡

Statistics

圣诞节快到了!Teo 已经决定装饰他的露台。

Teo 有一个长为 $n$ 米、宽为 $m$ 米的大型矩形露台。他决定以一种非常奇特的方式装饰露台:他没有把圣诞彩灯挂在露台边缘,而是把它们放在了地板上!

Teo 有 $2k$ 盏灯,每种颜色两盏,共 $k$ 种颜色。他将每盏灯放置在某个位置 $(x_i, y_i)$,其中 $x_i$ 表示距离露台左侧的距离,$y_i$ 表示距离底部的距离。

Teo 对他装饰露台的方式感到自豪,于是决定休息一天。但很快他就感到无聊了,于是又回到了露台。他开始数露台上的“漂亮矩形”。如果对于每种颜色,该颜色的两盏灯要么同时在矩形内部,要么同时在矩形外部,那么这个矩形就是“漂亮”的。如果一盏灯位于矩形边缘,则认为它在矩形内部。

左侧的矩形不漂亮。一盏蓝色灯在矩形内部,另一盏在外部。右侧的矩形是漂亮的。红色和蓝色灯在内部,黄色灯在外部。

Teo 意识到数漂亮矩形并不是一件容易的事。他想知道有多少个漂亮矩形,其角点距离露台底部和左侧的距离均为整数。我们考虑的所有矩形都与露台的边平行。现在轮到你出场了!请计算漂亮矩形的数量。

输入格式

第一行包含三个整数 $n, m, k$ ($1 \le n \le 150, 1 \le m \le 1\,000, 0 \le k \le 200\,000$),分别表示露台的长、宽以及灯的颜色数量。

接下来的 $k$ 行,每行包含四个数字 $x_1, y_1, x_2, y_2$ ($0 \le x_1, x_2 \le n, 0 \le y_1, y_2 \le m$),表示第 $i$ 种颜色的两盏灯的位置。

输出格式

在一行中输出漂亮矩形的数量。

子任务

子任务 分值 约束
1 26 对于每种颜色的灯,$x_1 = y_1 = 0$
2 12 $n, m \le 10, k \le 1\,000$
3 35 $m \le 150$
4 37 无附加约束

样例

输入 1

2 2 1
0 0 1 2

输出 1

3

输入 2

3 3 0

输出 2

36

输入 3

3 3 5
0 0 0 0
0 0 1 3
0 0 3 1
1 3 3 1
1 3 3 1

输出 3

7

说明

第一个样例的说明: 图片展示了第一个样例中所有的漂亮矩形。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.