logo AlgoBeat OnlineJudge
登录 注册

#215751. [2018 KAIST RUN Spring] QueryreuQ

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A string is palindrome, if the string reads the same backward and forward. For example, strings like “a”, “aa”, “appa”, “queryreuq” are all palindromes.

For given empty string , you should process following two queries:

  1. Add a lower case alphabet at the back of .
  2. Remove a character at the back of .

After processing a query, you should count the number of palindrome substring in . For string and integers , (), represents a substring from th to th character of . You should print out the number of integer pairs where is palindrome.

输入格式

Input consists of two lines.

In the first line, , the number of queries is given.

In the second line, the query is given as string of length . th character denotes the th query. is ‘-’ or lower case alphabet (‘a’, ‘b’, …, ‘z’) (without quotes).

If the character is ‘-’, you should remove a character at the back of . If the character is lower case alphabet, you should add a character at the back of .

It is guaranteed that length of is always positive after the query.

输出格式

Print out space-separated integers in the first line. -th integer should be the answer of the th query.

样例

样例输入 1

17
queryreuq--------

样例输出 1

1 2 3 4 5 7 9 11 13 11 9 7 5 4 3 2 1

数据范围与提示

Constraints