无码av一区二区三区无码,在线观看老湿视频福利,日韩经典三级片,成 人色 网 站 欧美大片在线观看

歡迎光臨散文網(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ó)家法律
陆河县| 陈巴尔虎旗| 瓦房店市| 张家界市| 涞源县| 金沙县| 桐城市| 台北县| 上林县| 栾城县| 永丰县| 罗山县| 北安市| 讷河市| 黔南| 习水县| 柘城县| 庆元县| 丰镇市| 图木舒克市| 治多县| 华蓥市| 黄山市| 清原| 柳州市| 克拉玛依市| 察雅县| 丹江口市| 苏尼特右旗| 西藏| 钟祥市| 丰台区| 开平市| 隆尧县| 云梦县| 株洲县| 安西县| 松江区| 西吉县| 石楼县| 天门市|