AtCoder Regular Contest 141
F
Well-defined Abbreviation
AtCoder
⌀ 4134
原题
← E→
翻译中…

Problem Statement

翻译中…

You are given $N$ srings $S_i\ (1\le i \le N)$ consisting of A, B, C, D.

翻译中…

Consider the operation below on a string $T$ consisting of A, B, C, D.

翻译中…
  • Repeat the following until $T$ contains none of the strings $S_i$ as a substring.
  • Choose an $S_i$ and one of its occurrences in $T$, remove that occurrence from $T$, and concatenate the remaining parts.
翻译中…

What is a substring? A substring of a string is its contiguous subsequence. For example, A, AB, and BC are substrings of ABC, while BA and AC are not.

翻译中…

We say that the string $T$ is bad when multiple strings can result from the operation above.

翻译中…

Determine whether a bad string exists.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^6$
  • $1 \leq |S_i| \leq 2 \times 10^6$
  • $|S_1|+|S_2|+\dots +|S_N| \leq 2 \times 10^6$
  • $S_i \neq S_j$ if $i\neq j$.
  • $S_i$ is a string consisting of A, B, C, D.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
S_1
S_2
\vdots
S_N

翻译中…

Output

翻译中…

If a bad string exists, print Yes.

翻译中…

Otherwise, print No.

翻译中…

样例

Input #1
3
A
B
C
Output #1
No
The only string we can get from $T$ is what remains after removing all occurrences of `A`, `B`, `C` from $T$.
Input #2
1
ABA
Output #2
Yes
For example, from $T=$ `ABABA`, we can get two strings: `AB` and `BA`, so $T$ is a bad string.
Input #3
4
CBA
ACB
AD
CAB
Output #3
Yes
题目信息
题号
arc141_f
时间限制
8 s
内存限制
1024 MB

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