Problem 3781 --I love string

3781: I love string

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
Mr X likes to play string games.

Mr X has an operation sequence. This operation sequence can be written as a string. For each operation, the next character of the operation sequence can be inserted before or after the current string. For example, my operation sequence is "aabac", suppose the sequence obtained after the first four operations is "baaa", then after the last operation, the string may become "baaac" or "cbaaa". It can be seen that there is only one operation method for the first operation. For other operations, there are only two methods of operation.

For each operation method, there will be a score. The smaller the lexicographic order of the final string, the higher the final score.

Then, for a given operation sequence, how many operation methods can get the maximum score. 

The two operation methods are different. If and only if there is a certain operation (not the first operation), one operation will be inserted before the current string, and the other operation will be inserted after the current string.
Enter a positive integer T (T≤10) on the first line to represent the number of test cases.

For each test case:

the first line contains a integer n (1≤n≤100000) to represent the length of the string.

the second line contains a string of lowercase letters , which represents the sequence of operations.
For each test case, output a line of a positive integer to represent the number of schemes, and the answer is modulo 1000000007
1
5
abcde
1

推荐代码 查看3781 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛