题解:CF2094D Tung Tung Sahur
题意
判断
思路
首先根据题意可知
code
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
string p,s;
cin>>p>>s;
int len1=p.size();
int len2=s.size();
if(len2<len1||2*len1<len2){//判断长度
cout<<"NO\n";
continue;
}
int i=0,j=0;
bool flag=1;
while(i<len1&&j<len2){
if(s[j]!=p[i]){
flag=0;
break;
}
int m=len1-i-1;
int t=min(len2-j-m,2);
if(t<1){
flag=0;
break;
}
int op=1;
if(j+1<len2&&s[j+1]==p[i]&&t>=2){
op=2;
}
j+=op;
i++;
}
if(i==len1&&j==len2&&flag==1){
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
}
return 0;
}