最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1744A - Number Replacement

2023-08-18 17:01 作者:您是打尖兒還是住店呢  | 我要投稿

An integer array a1,a2,…,an 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 x from the array a, and any letter of the English alphabet y.

Replace all occurrences of number x with the letter y.

For example, if we initially had an array a=[2,3,2,4,1], then we could transform it the following way:

Choose the number 2 and the letter c. After that a=[c,3,c,4,1].

Choose the number 3 and the letter a. After that a=[c,a,c,4,1].

Choose the number 4 and the letter t. After that a=[c,a,c,t,1].

Choose the number 1 and the letter a. After that a=[c,a,c,t,a].

After the transformation all letters are united into a string, in our example we get the string "cacta".

Having the array a and the string s determine if the string s could be got from the array a after the described transformation?

Input

The first line contains a single integer t (1≤t≤103) — the number of test cases.

Then the description of the test cases follows.

The first line of each test case contains a single integer n (1≤n≤50) — the length of the array a and the string s.

The second line of each test case contains exactly n integers: a1,a2,…,an (1≤ai≤50) — the elements of the array a.

The third line of each test case contains a string s of length n, consisting of lowercase English letters.

Output

For each test case, output "YES", if we can get the string s from the array a, and "NO" otherwise. You can output each letter in any case.

-----------------------------------------

使用以下過(guò)程將整數(shù)數(shù)組 a1,a2,…,an 轉(zhuǎn)換為小寫(xiě)英文字母數(shù)組:

雖然數(shù)組中至少有一個(gè)數(shù)字:

從數(shù)組 a 中選擇任意數(shù)字 x 和英文字母 y 中的任意字母。

將所有出現(xiàn)的數(shù)字 x 替換為字母 y。

例如,如果我們最初有一個(gè)數(shù)組 a=[2,3,2,4,1],那么我們可以按以下方式對(duì)其進(jìn)行轉(zhuǎn)換:

選擇數(shù)字 2 和字母 c。 之后a=[c,3,c,4,1]。

選擇數(shù)字 3 和字母 a。 之后a=[c,a,c,4,1]。

選擇數(shù)字 4 和字母 t。 之后a=[c,a,c,t,1]。

選擇數(shù)字 1 和字母 a。 之后a=[c,a,c,t,a]。

轉(zhuǎn)換后,所有字母都統(tǒng)一為一個(gè)字符串,在我們的示例中,我們得到字符串“cacta”。

讓數(shù)組a和字符串s確定在所描述的轉(zhuǎn)換之后是否可以從數(shù)組a中得到字符串s?

輸入

第一行包含一個(gè)整數(shù) t (1≤t≤103) — 測(cè)試用例的數(shù)量。

然后是測(cè)試用例的描述。

每個(gè)測(cè)試用例的第一行包含一個(gè)整數(shù) n (1≤n≤50) — 數(shù)組 a 和字符串 s 的長(zhǎng)度。

每個(gè)測(cè)試用例的第二行恰好包含 n 個(gè)整數(shù):a1,a2,…,an (1≤ai≤50) — 數(shù)組 a 的元素。

每個(gè)測(cè)試用例的第三行包含一個(gè)長(zhǎng)度為n的字符串s,由小寫(xiě)英文字母組成。

輸出

對(duì)于每個(gè)測(cè)試用例,如果我們可以從數(shù)組 a 中獲取字符串 s,則輸出“YES”,否則輸出“NO”。 您可以在任何情況下輸出每個(gè)字母。

--------------------------------

同樣用hashmap即可;

下面是代碼:


CF 1744A - Number Replacement的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
桐城市| 濉溪县| 阿勒泰市| 灌阳县| 永济市| 五大连池市| 高邮市| 博白县| 肥城市| 抚宁县| 黑河市| 乐山市| 和顺县| 青州市| 年辖:市辖区| 新兴县| 许昌市| 台前县| 汾阳市| 郧西县| 万年县| 长沙县| 中方县| 祁阳县| 高尔夫| 邯郸市| 元谋县| 汉中市| 庆阳市| 新营市| 伊川县| 松原市| 牟定县| 肥乡县| 泗水县| 唐海县| 麻城市| 和顺县| 大悟县| 灵石县| 喀喇沁旗|