题目描述
Problem Description
There are $ N $ arrays. Initially, each array has a length of $ M $ and contains integers in the order $ (1, 2, ..., M) $.
Takahashi decided to perform a total of $ Q $ operations on these $ N $ arrays. In the $ i $ -th ($1 \leq i \leq Q$) operation, he will do the following:
- Choose any one of the $ N $ arrays. In that array, move the integer $ a_i $ ($1 \leq a_i \leq M$) to the front. For example, if $ a_i = 2 $, choosing the array $ (5, 4, 3, 2, 1) $ and performing the operation will change the array to $ (2, 5, 4, 3, 1) $.
Takahashi's goal is to have all $ N $ arrays be exactly the same after the total of $ Q $ operations. Determine if it is possible for all $ N $ arrays to be exactly the same after the total of $ Q $ operations.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ Q $ $ a_1 $ $ a_2 $ $ ... $ $ a_Q $
Output Format
If it is possible for all $ N $ arrays to be exactly the same after the total of $ Q $ operations, output Yes. Otherwise, output No.
Sample Input and Output
Sample Input #1
2 2
3
2 1 2
Sample Output #1
Yes
Sample Input #2
3 2
3
2 1 2
Sample Output #2
No
Sample Input #3
2 3
3
3 2 1
Sample Output #3
Yes
Sample Input #4
3 3
6
1 2 2 3 3 3
Sample Output #4
No
Notes/Hints
Constraints
- $2 \leq N \leq 10^5$
- $2 \leq M \leq 10^5$
- $1 \leq Q \leq 10^5$
- $1 \leq a_i \leq M$
Sample Explanation 1
For example, you can perform the operations as shown in the figure. ![[MATH0]](/img/other/code_festival_2016_quala/gbanjthabot/E_2.png)
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分