#P15301. [ROI 2012 Day 2] army 汗国军队

    ID: 17380 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>2012ROI(俄罗斯)DP 套 DP状压 DP

[ROI 2012 Day 2] army 汗国军队

Background

Translation source: loj #5462. "ROI 2012 Day 2" Khanate Army.

Problem Description

When preparing for battle, Khan Girey numbered all warriors in his army with natural numbers from 11 to NN. Since the warriors are good at fighting but not at counting, no matter how they line up in a row, they will stand in an arbitrary order.

We call one or more warriors standing in a row a squad. If the warriors' numbers in the queue form a strictly increasing sequence, then the squad is called correct. Among all correct squads, Khan Girey chooses those with the largest number of warriors as assault squads. For example, in the queue of four warriors 1 3 2 41\ 3\ 2\ 4, the assault squads are 1 3 41\ 3\ 4 and 1 2 41\ 2\ 4, while the squad 1 41\ 4 is correct but not an assault squad.

Some warriors are Khan Girey's personal guards.

You need to write a program to compute how many different queue permutations make the Khan's guards form an assault squad.

Input Format

The first line of the input file contains a natural number NN (1≤N≤15)(1 \leq N \leq 15), the total number of warriors.

The second line contains a natural number KK (1≤K≤N)(1 \leq K \leq N), the number of the Khan's guards.

The third line contains KK distinct natural numbers (not exceeding NN), given in increasing order, representing the numbers of the Khan's guards. The numbers are separated by spaces.

Output Format

The output file should contain one integer, the number of different ways to arrange all warriors in a queue such that, in each arrangement, the Khan's guards form an assault squad.

5
3
1 3 4

11

3
3
1 2 3
1

1
1
1
1

Hint

In the first sample, the army consists of five warriors. The assault squad must consist of the three warriors numbered 1,3,41, 3, 4. There are 1111 queues that satisfy this condition: (1,3,2,5,4)(1, 3, 2, 5, 4), (1,3,5,2,4)(1, 3, 5, 2, 4), (1,3,5,4,2)(1, 3, 5, 4, 2), (1,5,3,2,4)(1, 5, 3, 2, 4), (1,5,3,4,2)(1, 5, 3, 4, 2), (2,1,3,5,4)(2, 1, 3, 5, 4), (2,1,5,3,4)(2, 1, 5, 3, 4), (2,5,1,3,4)(2, 5, 1, 3, 4), (5,1,3,2,4)(5, 1, 3, 2, 4), (5,1,3,4,2)(5, 1, 3, 4, 2), (5,2,1,3,4)(5, 2, 1, 3, 4).

The detailed additional constraints and scores for subtasks are as follows:

Subtask Score Additional Constraints
11 4040 1≤N≤81 \leq N \leq 8
22 1010 9≤N≤109 \leq N \leq 10
33 N=11N = 11
44 N=12N = 12
55 N=13N = 13
66 N=14N = 14
77 N=15N = 15

Translated by ChatGPT 5