CF294C.Shaass and Lights
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacent light which is already switched on.
He knows the initial state of lights and he's wondering how many different ways there exist to switch all the lights on. Please find the required number of ways modulo 1000000007 (109 + 7).
有 n 盏灯排成一行。这些灯从左到右依次编号为 1 到 n。初始时,其中一部分灯处于开启状态。Shaass 希望将所有灯都打开。在每一步中,他可以打开一盏灯(该灯在当前时刻必须是关闭的),前提是这盏灯至少有一个相邻的灯已经处于开启状态。
他已知灯的初始状态,并想知道有多少种不同的方式能将所有灯全部打开。请计算满足条件的方式总数,并对 1000000007(即 109+7)取模。
输入格式
The first line of the input contains two integers n and m where n is the number of lights in the sequence and m is the number of lights which are initially switched on, (1 ≤ n ≤ 1000, 1 ≤ m ≤ n). The second line contains m distinct integers, each between 1 to n inclusive, denoting the indices of lights which are initially switched on.
输入的第一行包含两个整数 n 和 m,其中 n 表示灯序列中的灯的数量,m 表示初始时处于开启状态的灯的数量(1 ≤ n ≤ 1000,1 ≤ m ≤ n)。第二行包含 m 个互不相同的整数,每个整数均在 1 到 n 之间(含端点),表示初始时处于开启状态的灯的索引。
输出格式
In the only line of the output print the number of different possible ways to switch on all the lights modulo 1000000007 (109 + 7).
在输出的唯一一行中,打印开启所有灯的不同可能方式的数量对 1000000007(即 109+7)取模的结果。
输入输出样例
输入#1
3 1 1
输出#1
1
输入#2
4 2 1 4
输出#2
2
输入#3
11 2 4 8
输出#3
6720
输入解题思路,AI测评打分。不知道怎么写?