Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- while (n--)
- {
- int f = 0;
- string a, b, s;
- cin >> a >> b;
- string s1 = a;
- string s2 = b;
- sort(a.begin(), a.end());
- sort(b.begin(), b.end());
- if (a == b and a.size() == b.size())
- {
- cout << "YES" << endl;
- continue;
- }
- else if (a.size() > b.size())
- {
- cout << "NO" << endl;
- continue;
- }
- for (int i = 0; i <= s2.size() - s1.size(); i++)
- {
- s = s2.substr(i, s1.size());
- sort(s.begin(), s.end());
- if (a == s)
- {
- f = 1;
- break;
- }
- }
- if (f)
- cout << "YES" << endl;
- else
- cout << "NO" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement