QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 256 MB Points totaux : 100

#10174. 丢失的表格

Statistiques

Er-Tostik 拥有一个大小为 $n \times m$ 的正整数表格。Aldar-Kose 决定捉弄 Er-Tostik 并偷走了这个表格,但他告诉了 Er-Tostik 每一行和每一列的最大值。只有当 Er-Tostik 能算出有多少种不同的表格满足这些最大值条件时,Aldar-Kose 才会归还表格。由于表格的数量可能非常大,Aldar-Kose 只要求算出该数量对 $10^9 + 7$ 取模的结果。请帮助 Er-Tostik 找回他的表格。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 2 \cdot 10^5$):表格的维度。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$):每一行的最大值。 第三行包含 $m$ 个整数 $b_1, b_2, \dots, b_m$ ($1 \le b_j \le 10^9$):每一列的最大值。

输出格式

输出一行,包含一个整数:满足条件的表格数量。由于答案可能非常大,请输出其对 $10^9 + 7$ 取模的结果。

请注意,由于 Aldar-Kose 非常顽皮,输入可能与任何表格都不相符。在这种情况下,正确答案显然为 $0$。

样例

输入格式 1

3 3
2 2 3
2 3 3

输出格式 1

89

输入格式 2

1 1
1
2

输出格式 2

0

输入格式 3

5 5
2 2 3 3 3
2 2 2 3 3

输出格式 3

49049891

输入格式 4

12 13
2 2 2 3 3 4 4 4 4 5 5 5
2 3 3 3 3 4 5 5 5 5 5 5 5

输出格式 4

808346164

输入格式 5

2 3
2 3
3 1 5

输出格式 5

0

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.