AT_ndpc2026_c.String

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given three strings S1,S2,S3S_1, S_2, S_3, each consisting of lowercase English letters.
Find the number of strings TT of length NN (also consisting of lowercase English letters) such that none of S1,S2,S3S_1, S_2, S_3 appear as a subsequence of TT. Output the answer modulo 998244353998244353.

给你三个字符串 S1,S2,S3S_1, S_2, S_3,每个均由小写英文字母组成。
求长度为 NN 的字符串 TT(也由小写英文字母组成)的个数,使得 S1,S2,S3S_1, S_2, S_3 均不作为 TT 的子序列出现。输出答案对 998244353998244353 取模的结果。

输入格式

The input is given from standard input in the following format:

NN
S1S_1 S2S_2 S3S_3

输入从标准输入中按以下格式给出:

NN
S1S_1 S2S_2 S3S_3

输出格式

Print the number of strings TT of length NN consisting of lowercase English letters such that none of S1,S2,S3S_1, S_2, S_3 appear as a subsequence of TT, modulo 998244353998244353.

输出满足以下条件的长度为 NN 的字符串 TT(由小写英文字母组成)的个数,对 998244353998244353 取模:S1,S2,S3S_1, S_2, S_3 均不作为 TT 的子序列出现。

输入输出样例

  • 输入#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 676676 strings of length 22 consisting of lowercase English letters. Among them, 11 string contains S2S_2 = de, and 5151 strings contain S3S_3 = f. These sets do not overlap. Therefore, the answer is 676−1−51=624676 - 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≤1031 \leq N \leq 10^3
  • S1,S2,S3S_1, S_2, S_3 are non-empty strings of lowercase English letters with length at most 1010
  • NN is an integer

样例 1 解释:
由小写英文字母组成的长度为 22 的字符串共有 676676 个。其中,有 11 个字符串包含 S2S_2 = de,有 5151 个字符串包含 S3S_3 = f。这两个集合互不相交。因此,答案为 676−1−51=624676 - 1 - 51 = 624。

样例 2 解释:
注意,题目条件中的 子序列(subsequence) 与 子串(substring) 不同。
例如,accb 包含 ab 作为子序列,因此不满足题目条件。

约束条件

  • 1≤N≤1031 \leq N \leq 10^3
  • S1,S2,S3S_1, S_2, S_3 是非空的小写英文字母字符串,且长度均不超过 1010
  • NN 是一个整数

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

首页