Skip to content

Instantly share code, notes, and snippets.

@jinnatul
Created December 20, 2019 15:05
Show Gist options
  • Save jinnatul/d90d5c7bbdaaa5141ff51b9f7430a6d6 to your computer and use it in GitHub Desktop.
Save jinnatul/d90d5c7bbdaaa5141ff51b9f7430a6d6 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
/// Typedef
typedef long long ll;
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 200005
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define mem(name, value) memset(name, value, sizeof(name))
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define case cout << "Case " << t++ << ": ";
typedef vector <ll> vll;
typedef set <ll> sll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;
int main() {
//freopen("/opt/Coding/clion code/input.txt", "r", stdin);
ll n, m, tc, num, t = 1;
sc1(tc);
while (tc--){
string aa, bb;
cin >> aa >> bb;
ll ln = aa.length();
ll ln2 = bb.length();
bool ok = false;
sort(aa.begin(), aa.end());
for (ll i = 0; i < ln2 - ln + 1; ++i) {
string temp = bb.substr(i, ln);
//cout << temp << endl;
sort(temp.begin(), temp.end());
if(aa == temp){
ok = true;
break;
}
}
if(ok) yes;
else no;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment