#P9244. [蓝桥杯 2023 省 B] 子串简写
[蓝桥杯 2023 省 B] 子串简写
Problem Description
A very new abbreviation method is becoming popular among programmers: for a string, keep only the first and last characters, and replace all characters between them with the length of that middle part. For example, internationalization is abbreviated as i18n, Kubernetes (note that the hyphen is not part of the string) is abbreviated as K8s, and Lanqiao is abbreviated as L5o, etc.
In this problem, we规定 that any string with length greater than or equal to can use this abbreviation method (strings with length less than do not qualify to use this abbreviation).
Given a string and two characters and , please compute how many substrings of that start with and end with can use this abbreviation method.
Input Format
The first line contains an integer .
The second line contains a string and two characters and .
Output Format
Output one integer representing the answer.
4
abababdb a b
6
Hint
[Sample Explanation]
The substrings that meet the conditions are as follows, where the substring is inside the square brackets:
[abab]abdb
[ababab]db
[abababdb]
ab[abab]db
ab[ababdb]
abab[abdb]
[Constraints and Conventions for Test Cases]
For of the testdata, .
For of the testdata, . contains only lowercase letters. Both and are lowercase letters.
denotes the length of the string .
Lanqiao Cup 2023 Provincial Contest B Group Problem G.
Translated by ChatGPT 5