CF1065E.Side Transmutations
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider some set of distinct characters A and some string S, consisting of exactly n characters, where each character is present in A.
You are given an array of m integers b (b1<b2<⋯<bm).
You are allowed to perform the following move on the string S:
- Choose some valid i and set k=bi;
- Take the first k characters of S=Prk;
- Take the last k characters of S=Suk;
- Substitute the first k characters of S with the reversed Suk;
- Substitute the last k characters of S with the reversed Prk.
For example, let's take a look at S= "abcdefghi" and k=2. Pr2= "ab", Su2= "hi". Reversed Pr2= "ba", Su2= "ih". Thus, the resulting S is "ihcdefgba".
The move can be performed arbitrary number of times (possibly zero). Any i can be selected multiple times over these moves.
Let's call some strings S and T equal if and only if there exists such a sequence of moves to transmute string S to string T. For the above example strings "abcdefghi" and "ihcdefgba" are equal. Also note that this implies S=S.
The task is simple. Count the number of distinct strings.
The answer can be huge enough, so calculate it modulo 998244353.
考虑某个由互不相同的字符组成的集合 A,以及某个恰好由 n 个字符构成的字符串 S,其中每个字符均属于 A。
给定一个长度为 m 的整数数组 b(满足 b1<b2<⋯<bm)。
你被允许对字符串 S 执行如下操作:
- 选择一个合法的下标 i,并令 k=bi;
- 取 S 的前 k 个字符,记为 Prk;
- 取 S 的后 k 个字符,记为 Suk;
- 将 S 的前 k 个字符替换为 Suk 的反转;
- 将 S 的后 k 个字符替换为 Prk 的反转。
例如,设 S= "abcdefghi",k=2。则 Pr2= "ab",Su2= "hi"。Pr2 的反转为 "ba",Su2 的反转为 "ih"。因此,操作后得到的 S 为 "ihcdefgba"。
该操作可执行任意多次(包括零次),且在所有操作中可重复选取任意下标 i。
我们称两个字符串 S 和 T 相等,当且仅当存在一串上述操作,能将 S 变换为 T。例如,前述例子中 "abcdefghi" 与 "ihcdefgba" 是相等的。注意,这自然蕴含 S=S。
本题任务很简单:统计本质不同的字符串个数。
答案可能非常大,因此请对 998244353 取模。
输入格式
The first line contains three integers n, m and ∣A∣ (2≤n≤109, 1≤m≤min(2n,2⋅105), 1≤∣A∣≤109) — the length of the strings, the size of the array b and the size of the set A, respectively.
The second line contains m integers b1,b2,…,bm (1≤bi≤2n, b1<b2<⋯<bm).
第一行包含三个整数 n、m 和 ∣A∣(2≤n≤109,1≤m≤min(2n,2⋅105),1≤∣A∣≤109),分别表示字符串的长度、数组 b 的大小以及集合 A 的大小。
第二行包含 m 个整数 b1,b2,…,bm(1≤bi≤2n,且 b1<b2<⋯<bm)。
输出格式
Print a single integer — the number of distinct strings of length n with characters from set A modulo 998244353.
输出一个整数——由字符集 A 中的字符构成的长度为 n 的不同字符串的数量,对 998244353 取模。
输入输出样例
输入#1
3 1 2 1
输出#1
6
输入#2
9 2 26 2 3
输出#2
150352234
输入#3
12 3 1 2 5 6
输出#3
1
说明/提示
Here are all the distinct strings for the first example. The chosen letters 'a' and 'b' are there just to show that the characters in A are different.
- "aaa"
- "aab" = "baa"
- "aba"
- "abb" = "bba"
- "bab"
- "bbb"
以下是第一个示例中的所有不同字符串。所选字母 “a” 和 “b” 仅用于表明集合 A 中的字符互不相同。
- “aaa”
- “aab” = “baa”
- “aba”
- “abb” = “bba”
- “bab”
- “bbb”
输入解题思路,AI测评打分。不知道怎么写?