QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 1024 MB Points totaux : 100

#5051. Namomo 子序列

Statistiques

“gshfd1jkhaRaadfglkjerVcvuy0gf” 是 Pang 教授说的话。

为了理解 Pang 教授的话,我们需要计算其中 namomo 子序列的数量。Pang 教授的话是一个包含 $n$ 个字符的字符串 $s$,其中每个字符要么是英文字母(大小写均可),要么是数字。$s$ 的第 $i$ 个字符记为 $s[i]$ ($1 \le i \le n$)。$s$ 的一个子序列 $t$ 由一组下标 $t_1, \dots, t_6$ 定义,满足 $1 \le t_1 < t_2 < \dots < t_6 \le n$。令 $compare(c_1, c_2)$ 为作用于两个字符的函数,当 $c_1 = c_2$ 时 $compare(c_1, c_2) = 1$,否则 $compare(c_1, c_2) = 0$。当且仅当对于任意 $1 \le i < j \le 6$,都有 $compare(s[t_i], s[t_j]) = compare(namomo[i], namomo[j])$ 时,称 $t$ 为 $s$ 的一个 namomo 子序列,其中 $namomo[x]$ 表示字符串 “namomo” 的第 $x$ 个字符 ($1 \le x \le 6$)。

输出给定字符串 $s$ 中 namomo 子序列的数量,结果对 998244353 取模。

输入格式

第一行包含一个长度为 $n$ 的字符串 $s$ ($6 \le n \le 1000000$)。$s$ 仅包含小写英文字母(‘a’ – ‘z’)、大写英文字母(‘A’ – ‘Z’)和数字(‘0’ – ‘9’)。

输出格式

输出一个整数,即答案对 998244353 取模的结果。

样例

输入 1

wohaha

输出 1

1

输入 2

momomo

输出 2

0

输入 3

gshfd1jkhaRaadfglkjerVcvuy0gf

输出 3

73

输入 4

retiredMiFaFa0v0

输出 4

33

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.