洛谷八连测string

来源:互联网 发布:淘宝衣服质检报告 编辑:程序博客网 时间:2024/05/24 06:49
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=30010;
char s[maxn],t[maxn];
int tt;
int main(){
 scanf("%d",&tt);
 //freopen("1.txt","w",stdout);
 while(tt--){
  memset(s,0,sizeof(s));
  memset(t,0,sizeof(t));
  scanf("%s%s",s,t); 
  int i=0,j=0,flag=false;
  while(i<strlen(s)&&j<strlen(t)){
   int l=i,cur1=0;
   char las=s[i]; ++i;
   while(i<strlen(s)&&(s[i]=='*'||s[i]==las)){
    if(s[i]=='*') cur1++;
    ++i;
   }
   int r=j;
   char las1=t[j]; ++j;
   while(j<strlen(t)&&t[j]==las1){
    ++j;
   }
   if(cur1){
    if((i-l+1)-cur1>(j-r+1)){
     //cout<<1<<endl;
     cout<<"No"<<endl;
     flag=true; break;
    }
   }
   else if(((i-l+1)!=(j-r+1))||(las1!=las)){
     //cout<<2<<endl;
     cout<<"No"<<endl;
     flag=true; break;
   }
  }
  if(flag) continue;
  if((i==strlen(s))&&(j==strlen(t))){
   cout<<"Yes"<<endl;
  }
  else{
   //cout<<2<<endl;
   cout<<"No"<<endl;
  }
 }
 return 0;
}
原创粉丝点击