#abc302c. C - Almost Equal
C - Almost Equal
Score : points
问题描述
给定 个长度为 的字符串 ,每个字符串仅包含小写英文字母,并且这些字符串两两不同。
确定是否可以重新排列这些字符串以得到一个新的字符串序列 ,满足以下条件:
- 对于所有整数 ,其中 ,可以通过将 中恰好一个字符更改为另一个小写英文字母,使其等于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given strings , each of length , consisting of lowercase English letter. Here, are pairwise distinct.
Determine if one can rearrange these strings to obtain a new sequence of strings such that:
- for all integers such that , one can alter exactly one character of to another lowercase English letter to make it equal to .
Constraints
- is a string of length consisting of lowercase English letters.
- are pairwise distinct.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if one can obtain a conforming sequence; print No
otherwise.
Sample Input 1
4 4
bbed
abcd
abed
fbed
Sample Output 1
Yes
One can rearrange them in this order: abcd
, abed
, bbed
, fbed
. This sequence satisfies the condition.
Sample Input 2
2 5
abcde
abced
Sample Output 2
No
No matter how the strings are rearranged, the condition is never satisfied.
Sample Input 3
8 4
fast
face
cast
race
fact
rice
nice
case
Sample Output 3
Yes
update @ 2024/3/10 08:29:19