Codeforces1194C

https://codeforc.es/contest/1194/problem/C
从p中取出一些字符放入s中使s与t相等
s是t子序列 t-s剩余部分是p的子集
c[]计数 多组清0

#include<bits/stdc++.h>
using namespace std;
#define forn(i,n)  for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
const int maxn=1e5+5;	//200堆 
const int INF=0x3f3f3f3f;


int a[maxn],sum[maxn],c[maxn];
int n,q;
string s,t,p;
int solve(){
	int i=0,j=0;
	int lens=s.size(),lent=t.size();
	while(i<lens && j<lent){
		if(s[i]==t[j])
			i++;
		else
			c[t[j]-'a']++;	//s中必缺 
		j++;
	}
	if(i<lens)	//s未完 t先完 说明s不是t子序列  
	{
		return 0;
	} 
	if(j<lent){
		for(;j<lent;j++){		//s中没有t中有 
			c[t[j]-'a']++;
		}
	}	
	for(char o:p){	 //s中没有t中也没有 - 
		c[o-'a']--;
	}
	for(int i=0;i<26;i++){
		if(c[i]>0)
			return 0;
	}
	return 1;
} 
int main(){
	
	
	cin>>q;
	while(q--){
		cin>>s>>t>>p;	//s是t子序列 t-s是p的子集 数量够
		memset(c,0,sizeof c);
		cout<<(solve()?"YES":"NO")<<endl;
	}
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值