CF1397A.Juggling Letters
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n strings s1,s2,…,sn consisting of lowercase Latin letters.
In one operation you can remove a character from a string si and insert it to an arbitrary position in a string sj ( j may be equal to i ). You may perform this operation any number of times. Is it possible to make all n strings equal?
输入格式
The first line contains t ( 1≤t≤10 ): the number of test cases.
The first line of each test case contains a single integer n ( 1≤n≤1000 ): the number of strings.
n lines follow, the i -th line contains si ( 1≤∣si∣≤1000 ).
The sum of lengths of all strings in all test cases does not exceed 1000 .
输出格式
If it is possible to make the strings equal, print "YES" (without quotes).
Otherwise, print "NO" (without quotes).
You can output each character in either lowercase or uppercase.
输入输出样例
输入#1
4 2 caa cbb 3 cba cba cbb 4 ccab cbac bca acbcc 4 acb caf c cbafc
输出#1
YES NO YES NO
说明/提示
In the first test case, you can do the following:
- Remove the third character of the first string and insert it after the second character of the second string, making the two strings "ca" and "cbab" respectively.
- Remove the second character of the second string and insert it after the second character of the first string, making both strings equal to "cab".
In the second test case, it is impossible to make all n strings equal.