Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T
You are given three strings ss, tt and pp consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.
During each operation you choose any character from pp, erase it from pp and insert it into string ss (you may insert this character anywhere you want: in the beginning of ss, in the end or between any two consecutive characters).
For example, if pp is aba, and ss is de, then the following outcomes are possible (the character we erase from pp and insert into ss is highlighted):
- aba →→ ba, de →→ ade;
 - aba →→ ba, de →→ dae;
 - aba →→ ba, de →→ dea;
 - aba →→ aa, de →→ bde;
 - aba →→ aa, de →→ dbe;
 - aba →→ aa, de →→ deb;
 - aba →→ ab, de →→ ade;
 - aba →→ ab, de →→ dae;
 - aba →→ ab, de →→ dea;
 
Your goal is to perform several (maybe zero) operations so that ss becomes equal to tt. Please determine whether it is possible.
Note that you have to answer qq independent queries.
The first line contains one integer qq (1≤q≤1001≤q≤100) — the number of queries. Each query is represented by three consecutive lines.
The first line of each query contains the string ss (1≤|s|≤1001≤|s|≤100) consisting of lowercase Latin letters.
The second line of each query contains the string tt (1≤|t|≤1001≤|t|≤100) consisting of lowercase Latin letters.
The third line of each query contains the string pp (1≤|p|≤1001≤|p|≤100) consisting of lowercase Latin letters.
For each query print YES if it is possible to make ss equal to tt, and NO otherwise.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
4
ab
acxb
cax
a
aaaa
aaabbcc
a
aaaa
aabbcc
ab
baaa
aaaaa
YES
YES
NO
NO
In the first test case there is the following sequence of operation:
- s=s= ab, t=t= acxb, p=p= cax;
 - s=s= acb, t=t= acxb, p=p= ax;
 - s=s= acxb, t=t= acxb, p=p= a.
 
In the second test case there is the following sequence of operation:
- s=s= a, t=t= aaaa, p=p= aaabbcc;
 - s=s= aa, t=t= aaaa, p=p= aabbcc;
 - s=s= aaa, t=t= aaaa, p=p= abbcc;
 - s=s= aaaa, t=t= aaaa, p=p= bbcc.
 
代码:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
string s,t,p;
int vis[maxn];
int dp[][];
string str;
int main()
{ int T;
cin>>T;
while(T--)
{
cin>>s>>t>>p;
str=s+p;
memset(vis,,sizeof(vis));
int len1=t.length();
int len2=str.length();
int len3=s.length();
int ans=;
memset(dp,,sizeof(dp));
for(int i=;i<=len1;i++)
{
for(int j=;j<=len3;j++)
{
if(t[i-]==s[j-])
{
dp[i][j]=max(dp[i][j],dp[i-][j-]+);
}
else
{
dp[i][j]=max(dp[i-][j],dp[i][j-]);
}
}
}
int flag=;
if(dp[len1][len3]==len3)
{
flag=;
}
if(flag==)
{
puts("NO");
continue;
}
else
{
for(int i=;i<len1;i++)
{
for(int j=;j<len2;j++)
{
if(str[j]==t[i]&&vis[j]==)
{
vis[j]=;
ans++;
break;
}
}
}
if(ans==len1)
{
puts("YES");
}
else
{
puts("NO");
}
} }
return ;
}
Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T的更多相关文章
- Educational Codeforces Round 68 (Rated for Div. 2)---B
		
http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace s ...
 - Educational Codeforces Round 68 (Rated for Div. 2)补题
		
A. Remove a Progression 签到题,易知删去的为奇数,剩下的是正偶数数列. #include<iostream> using namespace std; int T; ...
 - Educational Codeforces Round 68 (Rated for Div. 2)  C. From S To T (字符串处理)
		
C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...
 - Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)
		
D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...
 - Educational Codeforces Round 68 (Rated for Div. 2)D(SG函数打表,找规律)
		
#include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while ...
 - Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game
		
output standard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 ...
 - Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
		
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
 - Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
		
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
 - Educational Codeforces Round 43 (Rated for Div. 2)
		
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
 
随机推荐
- JVM进行篇
			
结合字节码指令理解Java虚拟机栈和栈帧 栈帧:每个栈帧对应一个被调用的方法,可以理解为一个方法的 ...
 - c语言学习笔记之typedef
			
这是我觉得这个博主总结的很好转载过来的 原地址:https://blog.csdn.net/weixin_41632560/article/details/80747640 C语言语法简单,但内涵却博 ...
 - JS 模仿京东键盘输入内容
			
css代码 .search { width: 300px; height: 80px; margin: 0 auto; position: relative; } .con { display: no ...
 - C#/.Net集成RabbitMQ
			
RabbitMQ简介 消息 (Message) 是指在应用间传送的数据.消息可以非常简单,比如只包含文本字符串. JSON 等,也可以很复杂,比如内嵌对象. 消息队列中间件 (Message Queu ...
 - JavaScript 防抖(debounce)和节流(throttle)
			
防抖函数 触发高频事件后,n秒内函数只会执行一次,如果n秒内高频事件再次被触发,则重新计算时间 /** * * @param {*} fn :callback function * @param {* ...
 - Linux中.bashrc与.bash_profile的对比
			
如果你平时在命令行上花费了大量时间,那么你可能会萌生出希望定制 Shell 环境的想法.今天本文就和大家讲解该如何实现你们的这个想法.其实可以通过创建别名.向环境变量 $PATH 添加新目录或更改 S ...
 - 学长小清新题表之UOJ 180.实验室外的攻防战
			
学长小清新题表之UOJ 180.实验室外的攻防战 题目描述 时针指向午夜十二点,约定的日子--\(2\)月\(28\)日终于到来了.随着一声枪响,伏特跳蚤国王率领着他的跳蚤大军们包围了 \(picks ...
 - hdfs学习(三)
			
HDFS 的 API 操作 使用url方式访问数据(了解) @Test public void urlHdfs() throws IOException { //1.注册url URL.setURLS ...
 - 朋友国企干了5年java,居然不知道Dubbo是做什么呢?我真信了
			
点赞再看,养成习惯,微信搜一搜[三太子敖丙]关注这个喜欢写情怀的程序员. 本文 GitHub https://github.com/JavaFamily 已收录,有一线大厂面试完整考点.资料以及我的系 ...
 - Windows Server2008RFTP隔离账户的搭建
			
Step1:添加用户 打开DOS命令, net user net user u1 123.com /add net user u2 123.com /add Step2:创建文件夹 Step3:修改用 ...