#K41492. Distinct Block Lengths in a Binary String

    ID: 26877 Type: Default 1000ms 256MiB

Distinct Block Lengths in a Binary String

Distinct Block Lengths in a Binary String

You are given a binary string of length \(n\) composed only of the characters '0' and '1'. A block is defined as a maximal substring where all characters are the same. For example, in the string "1100011110", the blocks are "11", "000", "1111", and "0".

Your task is to count the number of distinct lengths of blocks for '1's and '0's separately. That is, determine how many different block lengths exist for blocks consisting of '1's and how many for blocks consisting of '0's.

Note: A block is a contiguous segment of identical characters. For a string of length 0, both counts are 0.

inputFormat

The input is read from standard input (stdin) and consists of two lines:

  • The first line contains an integer \(n\), the length of the binary string.
  • The second line contains a binary string \(s\) of length \(n\) consisting only of characters '0' and '1'.

outputFormat

Output two integers separated by a space. The first integer is the number of distinct block lengths for '1's and the second integer is the number of distinct block lengths for '0's. The output should be written to standard output (stdout).

## sample
10
1100011110
2 2