問題一覧 > 通常問題

No.495 (^^*) Easy

レベル : / AI推定難易度 : 98 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 681
作問者 : butsurizuki / テスター : Nafmo2
お気に入りにしたユーザー ProblemId : 1413 / 自分の提出
問題文最終更新日: 2026-06-28 11:17:39
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 159 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。