QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 32 MB مجموع النقاط: 100

#10991. 着色

الإحصائيات

在一个 $2 \times n$ 的网格中,每个单元格都填有一个 $1$ 到 $n$ 之间的数字,使得每个数字在网格中恰好出现两次,且每一列包含两个不同的数字。下图展示了此类配置的一个示例。

我们希望将每个单元格涂成白色或灰色,要求同一列的单元格颜色不同,且包含相同数字的单元格颜色也不同。下图展示了对上图中网格进行此类涂色的一种方案。

请问存在多少种这样的涂色方案?

输入格式

标准输入的第一行包含一个整数 $n$ ($2 \le n \le 100$)。接下来的两行,每行包含 $n$ 个范围在 $[1, n]$ 之间的整数,由空格分隔。这些数字表示网格中对应单元格内填写的数字。

输出格式

标准输出的第一行且仅包含一行,输出一个整数,表示满足上述条件的网格涂色方案总数。

样例

输入 1

5
1 5 3 1 5
4 2 2 4 3

输出 1

4

说明

请注意,该样例描述了上图中的网格。

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.