1 Star 0 Fork 0

JJustRight/ACM-ICPC-Algorithms

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Uncompressing_Strings.cpp 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
ayush268 提交于 2017-10-28 02:52 +08:00 . Added String Problem of Uncompressing and its Algo
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{
string s,t;
cin>>s;
cin>>t;
int flag = 0;
int m = s.length();
int n = t.length();
if(t.length()<=s.length() || s[0]!=t[0])
{
cout<<"NO"<<endl;
}
else
{
int i=1,j=1;
while(i<m && j<n)
{
if(s[i]==t[j])
{
i++;
j++;
}
else if(s[i-1]==t[j])
{
j++;
}
else
{
flag = 1;
break;
}
}
if(flag==0)
{
while(j<n)
{
if(s[m-1]==t[j])
j++;
else
{
flag = 1;
break;
}
}
}
if(flag==1)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
}
}
}
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/jjustright/ACM-ICPC-Algorithms.git
git@gitee.com:jjustright/ACM-ICPC-Algorithms.git
jjustright
ACM-ICPC-Algorithms
ACM-ICPC-Algorithms
master

搜索帮助