Codeforces Round 283 (Div. 2)
D
Tennis Game
Codeforces
1900
原题
← CE →
翻译中…

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores $*t*$ points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total of $*s*$ sets, he wins the match and the match is over. Here $*s*$ and $*t*$ are some positive integer numbers.

翻译中…

To spice it up, Petya and Gena choose new numbers $*s*$ and $*t*$ before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores $*t*$ points and the match is over as soon as one of the players wins $*s*$ sets.

翻译中…

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numbers $*s*$ and $*t*$ for the given match are also lost. The players now wonder what values of $*s*$ and $*t*$ might be. Can you determine all the possible options?

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ — the length of the sequence of games ($1 ≤ *n* ≤ 10^{5}$).

翻译中…

The second line contains $*n*$ space-separated integers $*a*_{*i*}$. If $*a*_{*i*} = 1$, then the $*i*$-th serve was won by Petya, if $*a*_{*i*} = 2$, then the $*i*$-th serve was won by Gena.

翻译中…

It is not guaranteed that at least one option for numbers $*s*$ and $*t*$ corresponds to the given record.

翻译中…

Output

翻译中…

In the first line print a single number $*k*$ — the number of options for numbers $*s*$ and $*t*$.

翻译中…

In each of the following $*k*$ lines print two integers $*s*_{*i*}$ and $*t*_{*i*}$ — the option for numbers $*s*$ and $*t*$. Print the options in the order of increasing $*s*_{*i*}$, and for equal $*s*_{*i*}$ — in the order of increasing $*t*_{*i*}$.

翻译中…

样例

Input #1
5
1 2 1 2 1
Output #1
2
1 3
3 1
InputCopy OutputCopy
Input #2
4
1 1 1 1
Output #2
3
1 4
2 2
4 1
InputCopy OutputCopy
Input #3
4
1 2 1 2
Output #3
0
InputCopy OutputCopy
Input #4
8
2 1 2 1 1 1 1 1
Output #4
3
1 6
2 3
6 1
InputCopy OutputCopy
题目信息
题号
496D
时间限制
2 s
内存限制
256 MB
标签
二分

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