CF1397A.Juggling Letters
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
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?
给你 n 个字符串 s1,s2,…,sn,每个字符串均由小写拉丁字母组成。
在一次操作中,你可以从字符串 si 中移除一个字符,并将其插入到字符串 sj 的任意位置(j 可以等于 i)。你可以执行该操作任意多次。是否可能使所有 n 个字符串变得完全相同?
输入格式
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.
第一行包含一个整数 t(1≤t≤10):测试用例的数量。
每个测试用例的第一行包含一个整数 n(1≤n≤1000):字符串的数量。
接下来 n 行,第 i 行包含字符串 si(1≤∣si∣≤1000)。
所有测试用例中所有字符串的长度总和不超过 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.
如果可以使两个字符串相等,则输出 "YES"(不带引号)。
否则,输出 "NO"(不带引号)。
每个字符可以以小写或大写形式输出。
输入输出样例
输入#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.
在第一个测试用例中,你可以执行以下操作:
- 删除第一个字符串的第三个字符,并将其插入到第二个字符串的第二个字符之后,使两个字符串分别变为
"ca"和"cbab"。 - 删除第二个字符串的第二个字符,并将其插入到第一个字符串的第二个字符之后,使两个字符串均变为
"cab"。
在第二个测试用例中,无法使所有 n 个字符串相等。
输入解题思路,AI测评打分。不知道怎么写?