forked from matthewsamuel95/ACM-ICPC-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Uncompressing_Strings.cpp
64 lines (63 loc) · 1.25 KB
/
Uncompressing_Strings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#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;
}