No.495 (^^*) Easy
タグ : / 解いたユーザー数 681
作問者 :
butsurizuki
/ テスター :
Problem Statement
(^^*) is an emoticon devised by b-san.
(^^*) comes in two types: facing left and facing right.
(^^*) is facing left, and
(*^^) is facing right.
You received from b-san a string $S$, made by concatenating arbitrary numbers of only "(^^*)" and "(*^^)" in random order and appending '#' at the end.
Your mission is to count how many there are facing left and facing right, respectively.
For example, "(^^*)(^^*)(*^^)(*^^)(^^*)(*^^)(*^^)#" has 3 facing left and 4 facing right.
Input
$S$
The string $S$ is given on one line.
・Constraints
$S$ is a string made by concatenating arbitrary numbers of only "(^^*)" and "(*^^)" in random order and appending '#' at the end.
$1 \le |S| \le 100000$ (where $|S|$ is the length of the string $S$)
Output
Print the number facing left and the number facing right, in this order, on one line separated by a space.
A newline is required at the end of the output.
Sample
Sample 1
Input
(^^*)(^^*)(*^^)(*^^)(^^*)(*^^)(*^^)#
Output
3 4
This is the example from the problem statement.
Sample 2
Input
(^^*)(^^*)(^^*)#
Output
3 0
Sample 3
Input
#
Output
0 0
There are also cases where the string begins immediately with '#'.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。