QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 128 MB 總分: 100

#15267. Tricolor Binary Tree

统计

A binary tree can be represented as a sequence of characters consisting of 0, 1, and 2, which we call a "binary tree sequence $S$", according to the following rules:

$$ S = \begin{cases} 0 & \text{the node has no children} \\ 1S_1 & \text{the node has one child, where } S_1 \text{ is the sequence of the child} \\ 2S_1S_2 & \text{the node has two children, where } S_1 \text{ and } S_2 \text{ are the sequences of the two children} \end{cases} $$

For example, the binary tree shown in the figure below can be represented by the binary tree sequence $S=21200110$.

Your task is to color the nodes of a binary tree. Each node can be colored red, green, or blue. Furthermore, a node must have a different color from its children, and if a node has two children, those two children must also have different colors from each other. Given a binary tree sequence, find the maximum and minimum number of nodes that can be colored green.

Input

The input consists of a single line containing a binary tree sequence of no more than 10,000 characters.

Output

The output consists of a single line containing two integers, representing the maximum and minimum number of nodes that can be colored green, respectively.

Examples

Input 1

1122002010

Output 1

5 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.