CF1666D.Deletive Editing
入门
通过率:0%
时间限制:3.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Daisy loves playing games with words. Recently, she has been playing the following Deletive Editing word game with Daniel.
Daisy picks a word, for example, "DETERMINED". On each game turn, Daniel calls out a letter, for example, 'E', and Daisy removes the first occurrence of this letter from the word, getting "DTERMINED". On the next turn, Daniel calls out a letter again, for example, 'D', and Daisy removes its first occurrence, getting "TERMINED". They continue with 'I', getting "TERMNED", with 'N', getting "TERMED", and with 'D', getting "TERME". Now, if Daniel calls out the letter 'E', Daisy gets "TRME", but there is no way she can get the word "TERM" if they start playing with the word "DETERMINED".
Daisy is curious if she can get the final word of her choice, starting from the given initial word, by playing this game for zero or more turns. Your task it help her to figure this out.
黛西喜欢玩文字游戏。最近,她和丹尼尔一起玩一种名为“删减编辑”的文字游戏。
黛西先选定一个单词,例如:“DETERMINED”。在每一轮游戏中,丹尼尔喊出一个字母(例如 'E'),黛西则从该单词中删除首次出现的这个字母,得到新单词 “DTERMINED”。下一轮,丹尼尔再次喊出一个字母(例如 'D'),黛西删除其首次出现的位置,得到 “TERMINED”。接着,他们依次用字母 'I'、'N'、'D' 进行操作,分别得到 “TERMNED”、“TERMED”、“TERME”。此时,若丹尼尔再喊出字母 'E',黛西将得到 “TRME”;但若他们从单词 “DETERMINED” 开始游戏,则无法通过任何操作序列得到单词 “TERM”。
黛西很好奇:给定一个初始单词,她是否能通过零次或多次这样的操作,恰好得到自己想要的最终单词?你的任务就是帮她判断这一点。
输入格式
The first line of the input contains an integer n — the number of test cases (1≤n≤10000). The following n lines contain test cases.
Each test case consists of two words s and t separated by a space. Each word consists of at least one and at most 30 uppercase English letters; s is the Daisy's initial word for the game; t is the final word that Daisy would like to get at the end of the game.
输入的第一行包含一个整数 n —— 测试用例的数量(1≤n≤10000)。接下来的 n 行为测试用例。
每个测试用例由两个单词 s 和 t 组成,以空格分隔。每个单词均由至少一个、至多 30 个大写英文字母组成;其中 s 是 Daisy 在游戏开始时的初始单词,t 是 Daisy 希望在游戏结束时得到的目标单词。
输出格式
Output n lines to the output — a single line for each test case. Output "YES" if it is possible for Daisy to get from the initial word s to the final word t by playing the Deletive Editing game. Output "NO" otherwise.
向输出中打印 n 行——每个测试用例对应一行。如果 Daisy 能够通过玩“删减式编辑”(Deletive Editing)游戏,从初始单词 s 到达最终单词 t,则输出 "YES";否则输出 "NO"。
输入输出样例
输入#1
6 DETERMINED TRME DETERMINED TERM PSEUDOPSEUDOHYPOPARATHYROIDISM PEPA DEINSTITUTIONALIZATION DONATION CONTEST CODE SOLUTION SOLUTION
输出#1
YES NO NO YES NO YES
输入解题思路,AI测评打分。不知道怎么写?