欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1744A.Number Replacement
Number Replacement
An integer array is being transformed into an array of lowercase English letters using the following prodecure:
While there is at least one number in the array:
- Choose any number from the array , and any letter of the English alphabet .
- Replace all occurrences of number with the letter .
For example, if we initially had an array , then we could transform it the following way:
- Choose the number and the letter
c. After that . - Choose the number and the letter
a. After that . - Choose the number and the letter
t. After that . - Choose the number and the letter
a. After that .
After the transformation all letters are united into a string, in our example we get the string "cacta".
Having the array and the string determine if the string could be got from the array after the described transformation?
Input
The first line contains a single integer ) — the number of test cases.
Then the description of the test cases follows.
The first line of each test case contains a single integer () — the length of the array and the string .
The second line of each test case contains exactly integers: () — the elements of the array .
The third line of each test case contains a string of length , consisting of lowercase English letters.
Output
For each test case, output "YES", if we can get the string from the array , and "NO" otherwise. You can output each letter in any case.
Note
The first test case corresponds to the sample described in the statement.
In the second test case we can choose the number and the letter a.
In the third test case we can choose the number and the letter a, after that . Then we choose the number and the letter b and get .
In the fifth test case we can change all numbers one by one to the letter a.
Samples
7
5
2 3 2 4 1
cacta
1
50
a
2
11 22
ab
4
1 2 2 1
aaab
5
1 2 3 2 1
aaaaa
6
1 10 2 9 3 8
azzfdb
7
1 2 3 4 1 1 2
abababb
YES
YES
YES
NO
YES
YES
NO
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |