P1320 Compression Technology (Sequel Edition)

Description

Suppose a Chinese character is composed of an $N \times N$ dot-matrix pattern of $\texttt 0$ and $\texttt 1$. We generate a compression code according to the following rule. It is a sequence of consecutive counts: starting from the first symbol of the first row of the dot-matrix pattern, scan in writing order, left to right, top to bottom. The first number gives how many consecutive $\texttt 0$ there are, the second number gives how many consecutive $\texttt 1$ follow, the third number gives how many consecutive $\texttt 0$ follow, the fourth number gives how many consecutive $\texttt 1$ follow, and so on... For example, the following dot-matrix pattern: ``` 0001000 0001000 0001111 0001000 0001000 0001000 1111111 ``` The corresponding compression code is: $\texttt {7 3 1 6 1 6 4 3 1 6 1 6 1 3 7}$ (the first number is $N$, and the remaining numbers alternately give the counts of $\tt 0$ and $\tt 1$; the compression code guarantees $N \times N=$ the sum of these alternating counts).

Input Format

The character’s dot-matrix (no spaces between symbols).

Output Format

Output one line, the compression code.

Explanation/Hint

It is guaranteed that $3 \leq N \leq 200$. Translated by ChatGPT 5