Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define uns unsigned
- #define ll long long
- #define newline '\n'
- using namespace std;
- ///**************************contest setup
- inline void solve()
- {
- string s, t;
- cin >> s >> t;
- if (s.size() > t.size())
- {
- cout << "NO" << newline;
- return;
- }
- if (s == t)
- {
- cout << "YES" << newline;
- return;
- }
- vector < pair <char, int> > gs, gt;
- gs.push_back(make_pair(s[0], 1));
- for (int i = 1; s[i]; i++)
- if (gs.back().first == s[i])
- {
- gs.back().second++;
- }
- else
- {
- gs.push_back(make_pair(s[i], 1));
- }
- gt.push_back(make_pair(t[0], 1));
- for (int i = 1; t[i]; i++)
- if (gt.back().first == t[i])
- {
- gt.back().second++;
- }
- else
- {
- gt.push_back(make_pair(t[i], 1));
- }
- if (s.size() > t.size())
- {
- cout << "NO" << newline;
- return;
- }//*/
- //cout << (gs.size() == gt.size());
- for (int i = 0; i < max(gs.size(), gt.size()); i++)
- if (gs[i].first != gt[i].first or gs[i].second > gt[i].second)
- {
- cout << "NO" << newline;
- return;
- }
- cout << "YES" << newline;
- }
- int main()
- {
- int n;
- cin >> n;
- while (n--)
- solve();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement