Strong Password(贪心思想)
Monocarp finally got the courage to register on ForceCoders. He came up with a handle but is still thinking about the password.
He wants his password to be as strong as possible, so he came up with the following criteria:
- the length of the password should be exactly m;
- the password should only consist of digits from 00 to 99;
- the password should not appear in the password database (given as a string s) as a subsequence (not necessarily contiguous).
Monocarp also came up with two strings of length m: l and r, both consisting only of digits from 00 to 99. He wants the i-th digit of his password to be between li and ri, inclusive.
Does there exist a password that fits all criteria?
The first line contains a single integer t (1≤t≤1041≤≤104) — the number of testcases.
The first line of each testcase contains a string s (1≤|s|≤3⋅1051≤||≤3⋅105), consisting only of digits from 00 to 99 — the password database.
The second line contains a single integer m (1≤m≤101≤≤10) — the required length of the password.
The third line contains a string l (|l|=m||=), consisting only of digits from 00 to 99 — the lower restriction on each digit.
The fourth line contains a string r (|r|=m||=), consisting only of digits from 00 to 99 — the upper restriction on each digit. li≤ri≤ for all i from 11 to m.
The sum of lengths of s over all testcases doesn't exceed 3⋅1053⋅105.
For each testcase, print "YES" if there exists a password that fits all criteria. Print "NO" otherwise.
In the first testcase, Monocarp can choose password "50". It doesn't appear in s as a subsequence.
In the second testcase, all combinations of three digits, each of them being from 11 to 44, fit the criteria on l and r. However, all of them appear in s as subsequences. For example, "314" appears at positions [3,5,12][3,5,12] and "222" appears at positions [2,6,10][2,6,10].
In the third testcase, Monocarp can choose password "4321". Actually, that is the only password that fits the criteria on l and r. Luckily, it doesn't appear in s as a subsequence.
In the fourth testcase, only "49" and "59" fit the criteria on l and r. Both of them appear in s as subsequences.
In the fifth testcase, Monocarp can choose password "11".
__EOF__

本文链接:https://www.cnblogs.com/o-Sakurajimamai-o/p/17547698.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)