QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 256 MB Total points: 100

#11990. 三元组

Statistics

给定一个包含 $n$ 个整数对的有限多重集 $A$,以及另一个包含 $m$ 个整数三元组的有限多重集 $B$,我们定义 $A$ 和 $B$ 的积为一个多重集 $C$:

$$C = A * B = \{\langle a, c, d \rangle \mid \langle a, b \rangle \in A, \langle c, d, e \rangle \in B \text{ 且 } b = e\}$$

对于每个 $\langle a, b, c \rangle \in C$,其 BETTER 集定义为:

$$BETTER_C(\langle a, b, c \rangle) = \{\langle u, v, w \rangle \in C \mid \langle u, v, w \rangle \neq \langle a, b, c \rangle, u \geq a, v \geq b, w \geq c\}$$

作为三元组的多重集,我们定义 $C$ 的 TOP 子集(同样作为多重集)$TOP(C)$ 为:

$$TOP(C) = \{\langle a, b, c \rangle \in C \mid BETTER_C(\langle a, b, c \rangle) = \emptyset\}$$

你需要计算 $TOP(C)$ 的大小。

输入格式

输入包含多个测试用例。第一行是一个整数 $t$ ($1 \leq t \leq 10$),表示测试用例的数量。接下来是 $t$ 个测试用例。

每个测试用例包含三行。第一行包含两个整数 $n$ ($1 \leq n \leq 10^5$) 和 $m$ ($1 \leq m \leq 10^5$),分别对应 $A$ 和 $B$ 的大小。第二行包含 $2 \times n$ 个非负整数:

$$a_1, b_1, a_2, b_2, \dots, a_n, b_n$$

描述了多重集 $A$,其中 $1 \leq a_i, b_i \leq 10^5$。第三行包含 $3 \times m$ 个非负整数:

$$c_1, d_1, e_1, c_2, d_2, e_2, \dots, c_m, d_m, e_m$$

对应于 $B$ 中的 $m$ 个三元组,其中 $1 \leq c_i, d_i \leq 10^3$ 且 $1 \leq e_i \leq 10^5$。

输出格式

对于每个测试用例,输出 $TOP(C)$ 的大小。

样例

输入 1

2
5 9
1 1 2 2 3 3 3 3 4 2
1 4 1 2 2 1 4 1 1 1 3 2 3 2 2 4 1 2 2 4 3 3 2 3 4 1 3
3 4
2 7 2 7 2 7
1 4 7 2 3 7 3 2 7 4 1 7

输出 1

Case #1: 5
Case #2: 12

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.