AT_scpc2026_div1_b.Sushisushi Ruins

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

Archaeologist seokgukim is studying an inscription discovered at the Sushisushi ruins.

The stone tablet currently being studied has a string SS of length NN engraved on it, and scholars believe that a string TT of length MM appears in the inscription.

Over a long period of time, some part of the originally engraved text is said to have disappeared entirely. You want to restore the string using the following method.

  1. Delete a substring of length KK from TT. (1≤K<M1 \leq K < M)

  2. If the string after deletion appears as a substring of SS, this is called a valid restoration method.

Find the number of distinct valid restoration methods. Two valid restoration methods are considered different if at least one of the following differs: the length of the deleted substring, the position of the deleted substring, or the position where the string after deletion appears as a substring of SS.

考古学家石国金正在研究在寿司寿司遗址发现的一块铭文。

目前研究的石碑上刻有一长度为 NN 的字符串 SS,学者们认为其中包含一长度为 MM 的字符串 TT。

经过漫长岁月,原始铭文中某一部分据称已完全消失。你需采用以下方法恢复该字符串:

  1. 从 TT 中删除一个长度为 KK 的子串(1≤K<M1 \leq K < M);
  2. 若删除后的字符串作为子串出现在 SS 中,则称该恢复方法为有效恢复方法。

求不同有效恢复方法的总数。若两种有效恢复方法满足以下任一条件,则视为不同:被删除子串的长度不同、被删除子串在 TT 中的位置不同,或删除后所得字符串在 SS 中作为子串出现的位置不同。

输入格式

The input is given from Standard Input in the following format:

NN MM
SS
TT

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

NN MM
SS
TT

输出格式

Output the number of distinct valid restoration methods.

输出不同的有效恢复方法的数量。

输入输出样例

  • 输入#1

    4 4
    scsc
    scpc

    输出#1

    8

说明/提示

表示言語

/ /

Constraints

  • 1≤N,M≤200 0001 \leq N, M \leq 200\,000
  • Both SS and TT consist only of lowercase English letters.
  • All given numbers are integers.

表示语言

/ /

限制条件

  • 1≤N,M≤200 0001 \leq N, M \leq 200\,000
  • 字符串 SS 和 TT 均仅由小写英文字母组成。
  • 所有给定的数均为整数。

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

首页