Codeforces Round 1085 (Div. 1 + Div. 2)
A
1-1
Codeforces
800
原题
←B →
翻译中…

image

翻译中…

Let $n$ be a positive integer. Mario has a binary string$^{\text{∗}}$ $s$ of length $n$. In one move, he can choose any position $i$ ($2 \leq i \leq n-1$) such that it's between two 1's, i.e., $s_{i-1} = s_{i+1} = \texttt{1}$, and then set $s_i$ to either 0 or 1.

翻译中…

Mario can perform this operation as many times as he wants (possibly zero). What's the minimum and maximum number of 1's that can be in the resulting string?

翻译中…

$^{\text{∗}}$A binary string is a string whose characters are either 0 or 1.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains an integer $n$ ($3 \leq n \leq 100$) — the length of the string.

翻译中…

The second line of each test case contains a string $s$ of length $n$ consisting of characters 0 or 1.

翻译中…

Output

翻译中…

For each test case, output two integers — the minimum and maximum number of 1's in the resulting string after some number of moves.

翻译中…

Note

翻译中…

In the first test case, the minimum number of 1's that can be in the resulting string is $2$. This is done by transforming the string as follows: $$\mathtt{1}\underline{\mathtt{1}}\mathtt{1} \to \mathtt{101}.$$ The maximum number of 1's that can be in the resulting string is $3$, by doing nothing.

翻译中…

In the second test case, the minimum number of 1's that can be in the resulting string is $3$. This is done by transforming the string as follows: $$\mathtt{011}\underline{\mathtt{0}}\mathtt{11} \to \mathtt{01}\underline{\mathtt{1}}\mathtt{111} \to \mathtt{0101}\underline{\mathtt{1}}\mathtt{1} \to \mathtt{010101}.$$ The maximum number of 1's that can be in the resulting string is $5$. This is done by transforming the string as follows: $$\mathtt{011}\underline{\mathtt{0}}\mathtt{11} \to \mathtt{011111}.$$

翻译中…

样例

Input #1
4
3
111
6
011011
7
1011101
9
100101101
Output #1
2 3
3 5
4 7
5 7
InputCopy OutputCopy
题目信息
题号
2207A
时间限制
1 s
内存限制
256 MB
标签
贪心
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。