CF1397A.Juggling Letters

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given nn strings s1,s2,,sns_1, s_2, \ldots, s_n consisting of lowercase Latin letters.

In one operation you can remove a character from a string sis_i and insert it to an arbitrary position in a string sjs_j ( jj may be equal to ii ). You may perform this operation any number of times. Is it possible to make all nn strings equal?

输入格式

The first line contains tt ( 1t101 \le t \le 10 ): the number of test cases.

The first line of each test case contains a single integer nn ( 1n10001 \le n \le 1000 ): the number of strings.

nn lines follow, the ii -th line contains sis_i ( 1si10001 \le \lvert s_i \rvert \le 1000 ).

The sum of lengths of all strings in all test cases does not exceed 10001000 .

输出格式

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 nn strings equal.

首页