#P5337. [TJOI2019] 甲苯先生的字符串
[TJOI2019] 甲苯先生的字符串
Background
TJOI2019 D1T1.
Source file name: str.*.
Time limit: 1 s. Memory limit: 128 M.
Problem Description
One day, Xiao Toluene received a divine message. He wants to write it down, but cannot reveal the secret, so he decides to record it in a special way.
The divine message is a string, denoted as . contains only lowercase letters. Now Xiao Toluene wants to write down the message as another string, denoted as . also contains only lowercase letters. The requirement is: any two adjacent letters in must not appear adjacent in .
Given the length of , Xiao Toluene wants to know how many different strings he can write. Output the number of valid strings modulo .
Input Format
The first line contains a single positive integer , representing the length of string .
The second line contains a string, representing string .
Output Format
Output one integer, representing the total number of strings that Xiao Toluene can write. Take the result modulo .
2
ab
675
Hint
For of the testdata, .
For of the testdata, , .
Note: The adjacency restriction requires the same order. For example, in the sample, must not contain , and only is forbidden, but is allowed.
Translated by ChatGPT 5