欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1397A.Juggling Letters
Juggling Letters
You are given strings consisting of lowercase Latin letters.
In one operation you can remove a character from a string and insert it to an arbitrary position in a string ( may be equal to ). You may perform this operation any number of times. Is it possible to make all strings equal?
Input
The first line contains (): the number of test cases.
The first line of each test case contains a single integer (): the number of strings.
lines follow, the -th line contains ().
The sum of lengths of all strings in all test cases does not exceed .
Output
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.
Note
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 strings equal.
Samples
4
2
caa
cbb
3
cba
cba
cbb
4
ccab
cbac
bca
acbcc
4
acb
caf
c
cbafc
YES
NO
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |