magic string

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

You are given n strings s1, s2, s3......sn, each of length M, consisting of lowercase English letter.

Here, s[i] are pairwise distinct.


Determine if one can rearrange these strings to obtain a new sequence of strings t1, t2, t3...t4 such that:


for all integers i such that 1 ≤ i < n, one can alter exactly one character of t[i] to another lowercase English letter to make it equal to t[i + 1].


Input

2 ≤ N ≤ 8

1 ≤ M ≤ 5

s[i] is a string of length M consisting of lowercase English letters. (1 ≤ i ≤ N)

s[i] are pairwise distinct.


Output

Print "Yes" if it is possible to obtain a conforming sequence; otherwise, print "No".

SampleInput
8 4
fast
face
cast
race
fact
rice
nice
case
SampleOutput
Yes
Submit
题目统计信息详细
总AC数8
通过人数5
尝试人数5
总提交量9
AC率55.56%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: