CF1065E.Side Transmutations

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider some set of distinct characters AA and some string SS, consisting of exactly nn characters, where each character is present in AA.

You are given an array of mm integers bb (b1<b2<⋯<bmb_1 \lt b_2 \lt \dots \lt b_m).

You are allowed to perform the following move on the string SS:

  1. Choose some valid ii and set k=bik = b_i;
  2. Take the first kk characters of S=PrkS = Pr_k;
  3. Take the last kk characters of S=SukS = Su_k;
  4. Substitute the first kk characters of SS with the reversed SukSu_k;
  5. Substitute the last kk characters of SS with the reversed PrkPr_k.

For example, let's take a look at S=S = "abcdefghi" and k=2k = 2. Pr2=Pr_2 = "ab", Su2=Su_2 = "hi". Reversed Pr2=Pr_2 = "ba", Su2=Su_2 = "ih". Thus, the resulting SS is "ihcdefgba".

The move can be performed arbitrary number of times (possibly zero). Any ii can be selected multiple times over these moves.

Let's call some strings SS and TT equal if and only if there exists such a sequence of moves to transmute string SS to string TT. For the above example strings "abcdefghi" and "ihcdefgba" are equal. Also note that this implies S=SS = S.

The task is simple. Count the number of distinct strings.

The answer can be huge enough, so calculate it modulo 998244353998244353.

考虑某个由互不相同的字符组成的集合 AA,以及某个恰好由 nn 个字符构成的字符串 SS,其中每个字符均属于 AA。

给定一个长度为 mm 的整数数组 bb(满足 b1<b2<⋯<bmb_1 \lt b_2 \lt \dots \lt b_m)。

你被允许对字符串 SS 执行如下操作:

  1. 选择一个合法的下标 ii,并令 k=bik = b_i;
  2. 取 SS 的前 kk 个字符,记为 PrkPr_k;
  3. 取 SS 的后 kk 个字符,记为 SukSu_k;
  4. 将 SS 的前 kk 个字符替换为 SukSu_k 的反转;
  5. 将 SS 的后 kk 个字符替换为 PrkPr_k 的反转。

例如,设 S=S = "abcdefghi",k=2k = 2。则 Pr2=Pr_2 = "ab",Su2=Su_2 = "hi"。Pr2Pr_2 的反转为 "ba",Su2Su_2 的反转为 "ih"。因此,操作后得到的 SS 为 "ihcdefgba"。

该操作可执行任意多次(包括零次),且在所有操作中可重复选取任意下标 ii。

我们称两个字符串 SS 和 TT 相等,当且仅当存在一串上述操作,能将 SS 变换为 TT。例如,前述例子中 "abcdefghi" 与 "ihcdefgba" 是相等的。注意,这自然蕴含 S=SS = S。

本题任务很简单:统计本质不同的字符串个数。

答案可能非常大,因此请对 998244353998244353 取模。

输入格式

The first line contains three integers nn, mm and ∣A∣|A| (2≤n≤1092 \le n \le 10^9, 1≤m≤min(n2,2⋅105)1 \le m \le min(\frac n 2, 2 \cdot 10^5), 1≤∣A∣≤1091 \le |A| \le 10^9) — the length of the strings, the size of the array bb and the size of the set AA, respectively.

The second line contains mm integers b1,b2,…,bmb_1, b_2, \dots, b_m (1≤bi≤n21 \le b_i \le \frac n 2, b1<b2<⋯<bmb_1 \lt b_2 \lt \dots \lt b_m).

第一行包含三个整数 nn、mm 和 ∣A∣|A|(2≤n≤1092 \le n \le 10^9,1≤m≤min⁡(n2,2⋅105)1 \le m \le \min(\frac{n}{2}, 2 \cdot 10^5),1≤∣A∣≤1091 \le |A| \le 10^9),分别表示字符串的长度、数组 bb 的大小以及集合 AA 的大小。

第二行包含 mm 个整数 b1,b2,…,bmb_1, b_2, \dots, b_m(1≤bi≤n21 \le b_i \le \frac{n}{2},且 b1<b2<⋯<bmb_1 \lt b_2 \lt \dots \lt b_m)。

输出格式

Print a single integer — the number of distinct strings of length nn with characters from set AA modulo 998244353998244353.

输出一个整数——由字符集 AA 中的字符构成的长度为 nn 的不同字符串的数量,对 998244353998244353 取模。

输入输出样例

  • 输入#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 AA are different.

  1. "aaa"
  2. "aab" = "baa"
  3. "aba"
  4. "abb" = "bba"
  5. "bab"
  6. "bbb"

以下是第一个示例中的所有不同字符串。所选字母 “a” 和 “b” 仅用于表明集合 AA 中的字符互不相同。

  1. “aaa”
  2. “aab” = “baa”
  3. “aba”
  4. “abb” = “bba”
  5. “bab”
  6. “bbb”

输入解题思路,AI测评打分。不知道怎么写?

首页