D.Backspace
作者:互联网
Harbour.Space Scholarship Contest 2021-2022 (open for everyone, rated, Div. 1 + Div. 2)
从后往前取
#include<math.h> #include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<map> #include<set> #include <queue> #include<stack> #include<string.h> using namespace std; typedef long long ll; const int N=1e6+10; const double INF=1000000009; const int mod=998244353; string a,b; int main() { int t;cin>>t; string a,b; while(t--) { cin>>a>>b; reverse(a.begin(),a.end()); reverse(b.begin(),b.end()); int len1=a.length(),len2=b.length(); int j=0,f=0; for(int i=0;i<len2;i++) { while(j<len1&&a[j]!=b[i]) j+=2; if(j>=len1) {f=1;break;} else if(a[j]==b[i]) j++; } if(f==1) cout<<"NO"<<endl; else cout<<"YES"<<endl; } }
标签:const,int,length,len1,Backspace,include 来源: https://www.cnblogs.com/hahaee/p/15048246.html