-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode2094D.cpp
More file actions
48 lines (38 loc) · 1006 Bytes
/
Copy pathcode2094D.cpp
File metadata and controls
48 lines (38 loc) · 1006 Bytes
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
/*
* Contest : Codeforces
* Problem : 2094D - Tung Tung Sahur
* Link : https://codeforces.com/contest/2094/problem/D
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int two_pointers(int &l, int &r, int n, string str) {
cerr << str << ":\n";
cerr << "l: " << l << " r: " << r << '\n';
while (r < n && str[r] == str[l]) { r++; }
int ret = r - l;
l = r;
cerr << ret << '\n';
return ret;
}
bool solve() {
string p, s;
cin >> p >> s;
cerr << "--------------------------\n";
int pl = 0, pr = 0, pn = p.size(),
sl = 0, sr = 0, sn = s.size();
while (pl < pn) {
int plen = two_pointers(pl, pr, pn, p),
slen = two_pointers(sl, sr, sn, s);
if (slen > 2 * plen || plen > slen || p[pl - 1] != s[sl - 1]) return false;
}
if (sl < sn) return false;
return true;
}
int main() {
fastio
int tc; cin >> tc;
while (tc--) cout << (solve() ? "YES" : "NO") << "\n";
return 0;
}