#P2444. Infinite Safe Binary Code

    ID: 15715 Type: Default 1000ms 256MiB

Infinite Safe Binary Code

Infinite Safe Binary Code

The Binary Virus Inspection Committee has discovered that certain fixed binary substrings represent virus codes. A binary code is considered safe if it does not contain any of these virus code segments as a substring.

Given a set of virus code segments \(\{s_1, s_2, \dots, s_n\}\), determine whether an infinite safe binary code exists. In other words, decide if there exists an infinite binary string that does not contain any virus pattern as a contiguous substring.

For example:

  • If the virus set is \(\{011,\ 11,\ 00000\}\), one possible infinite safe code is 010101\ldots.
  • If the virus set is \(\{01,\ 11,\ 000000\}\), then no infinite safe binary code exists.

Your task is to output "Yes" if there exists an infinite safe binary code, and "No" otherwise.

inputFormat

The first line contains an integer \(n\) (\(1 \leq n \leq 100\)) that denotes the number of virus code segments. Each of the next \(n\) lines contains a non-empty binary string representing a virus code segment. Each virus string consists only of characters '0' and '1' and has length at most 100.

outputFormat

Output a single line with either "Yes" if there exists an infinite safe binary code, or "No" if there does not exist such a code.

sample

3
011
11
00000
Yes