QOJ.ac

QOJ

Time Limit: 2.0 s Memory Limit: 2048 MB Total points: 100

#14928. Pair Linked Mokepon

Statistics

著名的 Mokepon 游戏可以表示为一个包含 $n$ 个关卡的列表,关卡中放置有特殊道具,玩家从关卡 1 开始。每个道具都有一个标识符 $id$($2 \le id \le n$)(且没有两个道具具有相同的标识符),玩家必须拥有标识符为 $i$ 的道具才能从关卡 $i-1$ 移动到关卡 $i$。关卡中可以有多个(包括零个)道具,玩家可以捡起并携带无限数量的道具。游戏的目标是到达最后一个关卡:关卡 $n$。

你和你的朋友觉得这个游戏太简单了,所以你们决定将两场 Mokepon 游戏关联起来:你的游戏有 $n_A$ 个关卡,你朋友的游戏有 $n_B$ 个关卡。然而,特殊道具可能会出现在任一游戏中,现在由二元组 $(id, \text{A} \text{ 或 } \text{B})$ 唯一标识:即它的标识符,以及它来自哪个游戏。要在某个游戏中前进到关卡 $i$,你们中的任何一个人都必须已经捡起了该游戏对应的标识符为 $i$ 的道具。

游戏会随机将道具放置在两个游戏的各个关卡中,因此并非所有的道具放置方式都能通关。你的目标是计算有多少种道具分配方案,使得你们两人都能在各自的游戏中到达终点关卡。由于这个数量可能很大,请对质数 $p$ 取模。

如果存在至少一个关卡,其上的道具集合不同,则我们称两种道具分配方案是不同的。

输入格式

输入只有一行,包含三个空格分隔的整数 $n_A$、$n_B$ 和 $p$($2 \le n_A, n_B \le 3 \cdot 10^3$,$10^8 \le p \le 10^9 + 7$)—— 分别表示你和你的朋友的游戏中的关卡数量,以及用于计算的模数。

保证 $p$ 是一个质数。

输出格式

输出一个整数,表示两个玩家都能通关各自游戏的道具分配方案数,模 $p$。

样例

输入样例 1

2 2 1000000007

输出样例 1

8

输入样例 2

15 20 998244353

输出样例 2

937612

说明

在第一个样例中,有两个特殊道具:$(2, A)$ 和 $(2, B)$,分别对应游戏 A 和 B。因此共有 $4^2 = 16$ 种可能的道具关卡放置方案。以下列出了 8 种获胜的可能性(采用 (关卡, 游戏) 的表示法来表示道具的位置),并配有前两种可能性的图示。

  1. (1, A); (1, A):两位玩家都可以立即前进到各自的终点关卡。
  2. (1, A); (2, A):第一位玩家解锁了他们的终点关卡,此时第二位玩家也可以前进。
  3. (1, A); (1, B)
  4. (1, B); (1, A)
  5. (1, B); (1, B)
  6. (1, B); (2, A)
  7. (2, B); (1, A)
  8. (2, B); (1, B)

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.