#C10654. Longest Increasing Subsequence of IP Addresses

    ID: 39883 Type: Default 1000ms 256MiB

Longest Increasing Subsequence of IP Addresses

Longest Increasing Subsequence of IP Addresses

Given a sequence of IP address strings, determine the length of the longest subsequence in which each subsequent IP address has strictly more digits than the previous one.

The problem is defined as follows:

Let \( S = \{ s_1, s_2, \dots, s_n \} \) be a list of IP address strings. Find the maximum length \( L \) of a subsequence \( \{ s_{i_1}, s_{i_2}, \dots, s_{i_L} \} \) (where \( i_1 < i_2 < \dots < i_L \)) such that:

\[ \text{len}(s_{i_1}) < \text{len}(s_{i_2}) < \dots < \text{len}(s_{i_L}) \]

Your solution should read the input from standard input and write the result to standard output. The first line of input contains an integer \( n \) representing the number of IP addresses. The following \( n \) lines each contain an IP address string.

inputFormat

The first line of input is a single integer \( n \) (\( 1 \leq n \leq 10^5 \)) indicating the number of IP addresses. Each of the next \( n \) lines contains a string representing an IP address.

outputFormat

A single integer representing the length of the longest subsequence where each IP address has more digits than the previous one.

## sample
1
19216801
1

</p>