CRB and String

阅读: 评论:0

CRB and String

CRB and String

CRB and String (字符串思维题)

Problem Description:
CRB has two strings s and t.
In each step, CRB can select arbitrary character c of s and insert any character d (d ≠ c) just after it.
CRB wants to convert s to t. But is it possible?
Input:
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case there are two strings s and t, one per line.
1 ≤ T ≤ 105
1 ≤ |s| ≤ |t| ≤ 105
All strings consist only of lowercase English letters.
The size of each input file will be less than 5MB.
Output:
For each test case, output “Yes” if CRB can convert s to t, otherwise output “No”.

当s为 t 的子序列 ,并且 s 从第一位开始相同的字母的个数要大于等于 t ,则输出Yes,否则No。

#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int T;cin>>T;while(T--){string s,t;cin>>s>>t;int k=0,l=0,r=0;for(int i=0;i<t.size();i++)if(k<s.size()&&s[k]==t[i]) k++;while(s[l]==s[l+1]&&l<s.size()-1) l++;while(t[r]==t[r+1]&&r<t.size()-1) r++;if(k==s.size()&&s[0]==t[0]&&l>=r) cout<<"Yesn";else cout<<"Non";}return 0;
}

本文发布于:2024-01-30 18:13:46,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170660963021891.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:CRB   String
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23