AT_ndpc2026_c.String
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given three strings S1,S2,S3, each consisting of lowercase English letters.
Find the number of strings T of length N (also consisting of lowercase English letters) such that none of S1,S2,S3 appear as a subsequence of T. Output the answer modulo 998244353.
给你三个字符串 S1,S2,S3,每个均由小写英文字母组成。
求长度为 N 的字符串 T(也由小写英文字母组成)的个数,使得 S1,S2,S3 均不作为 T 的子序列出现。输出答案对 998244353 取模的结果。
输入格式
The input is given from standard input in the following format:
N
S1 S2 S3
输入从标准输入中按以下格式给出:
N
S1 S2 S3
输出格式
Print the number of strings T of length N consisting of lowercase English letters such that none of S1,S2,S3 appear as a subsequence of T, modulo 998244353.
输出满足以下条件的长度为 N 的字符串 T(由小写英文字母组成)的个数,对 998244353 取模:S1,S2,S3 均不作为 T 的子序列出现。
输入输出样例
输入#1
2 abc de f
输出#1
624
输入#2
4 ab ab ab
输出#2
453125
输入#3
1000 atcoder algorithm lectures
输出#3
669410767
说明/提示
Sample 1 Explanation:
There are 676 strings of length 2 consisting of lowercase English letters. Among them, 1 string contains S2 = de, and 51 strings contain S3 = f. These sets do not overlap. Therefore, the answer is 676−1−51=624.
Sample 2 Explanation:
Note that subsequence in the condition is different from substring.
For example, accb contains ab as a subsequence, so it does not satisfy the condition.
Constraints
- 1≤N≤103
- S1,S2,S3 are non-empty strings of lowercase English letters with length at most 10
- N is an integer
样例 1 解释:
由小写英文字母组成的长度为 2 的字符串共有 676 个。其中,有 1 个字符串包含 S2 = de,有 51 个字符串包含 S3 = f。这两个集合互不相交。因此,答案为 676−1−51=624。
样例 2 解释:
注意,题目条件中的 子序列(subsequence) 与 子串(substring) 不同。
例如,accb 包含 ab 作为子序列,因此不满足题目条件。
约束条件
- 1≤N≤103
- S1,S2,S3 是非空的小写英文字母字符串,且长度均不超过 10
- N 是一个整数
输入解题思路,AI测评打分。不知道怎么写?