题库练习 Count Good Substrings
← 上一题 下一题 →

A9478 | Count Good Substrings

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after the merging step it will become "aba".

Given a string, you have to find two values:

1. the number of good substrings of even length;
2. the number of good substrings of odd length.

输入格式

The first line of the input contains a single string of length $n$ ( $1<=n<=10^{5}$ ). Each character of the string will be either 'a' or 'b'.

输出格式

Print two space-separated integers: the number of good substrings of even length and the number of good substrings of odd length.

输入输出样例

输入 #1
bb
输出 #1
1 2
输入 #2
baab
输出 #2
2 4
输入 #3
babb
输出 #3
2 5
输入 #4
babaa
输出 #4
2 7
C++ 编辑器
输入
输出