#P10099. [ROIR 2023] 美丽序列 (Day 2)

    ID: 10775 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2023Special Judge动态规划优化状压 DPROIR(俄罗斯)

[ROIR 2023] 美丽序列 (Day 2)

Background

Translated from ROIR 2023 D2T2

You are given an integer set AA, where all elements are between 11 and 88.

A sequence [a1,a2,,an][a_1, a_2, \dots , a_n] of length nn consisting of integers from set AA is called beautiful if, for any number xx, the distance between any two elements equal to xx in the sequence is at least xx. In other words, for any number xx and any 1i<jn1 \le i < j \le n, if ai=aj=xa_i = a_j = x, then the inequality jixj - i \ge x must hold. Such a sequence aa is called a beautiful sequence.

For example, when A={1,2,3,4,5}A=\{1,2,3,4,5\}, the sequence [2,3,2,4,3,1,1,4][2,3,2,4,3,1,1,4] is beautiful, while [1,1,4,5,1,4][1,1,4,5,1,4] is not beautiful, because the distance between the two 44's in this sequence is 33.

Problem Description

Given the number nn and the set AA, find the number of beautiful sequences of length nn that satisfy the requirement, modulo 109+710^9 + 7.

Input Format

The first line contains two integers nn and mm, representing the length of the sequence and the number of elements in set AA.

The second line gives mm distinct positive integers in ascending order, each not exceeding 88, representing the elements of set AA.

Output Format

Output one integer, the remainder of the number of beautiful sequences modulo 109+710^9 + 7.

3 2
1 2
5

Hint

In the sample, the beautiful sequences are [1,1,1],[1,1,2],[1,2,1],[2,1,1],[2,1,2][1, 1, 1],[1, 1, 2],[1, 2, 1],[2, 1, 1],[2, 1, 2]. The sequences [2,2,2],[1,2,2],[2,2,1][2, 2, 2],[1, 2, 2],[2, 2, 1] are not beautiful, because in each of these three sequences there are two elements with value 22 whose distance is 11.

This problem uses bundled testdata.

Subtask ID Score Special Properties
11 55 A={1,2},n10A=\{1,2\},n\le10
22 1010 A={1,2},n30A=\{1,2\},n\le30
33 1515 A={1,2}A=\{1,2\}
44 2020 A={1,k}A=\{1,k\}2k82\le k\le8
55 3030 No element in AA is greater than 55
66 2020 No special properties

Constraints: for 100%100\% of the testdata, 1n100,1m81 \le n \le 100,1 \le m \le 8

Translated by ChatGPT 5