Advertisement
Rakibul_Ahasan

Codeforces(A - Shuffle Hashing)

Dec 20th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(string p,string q)
  5. {
  6.     int l=p.length();
  7.     int L=q.length();
  8.     sort(p.begin(),p.end());
  9.  
  10.     for(int i=0; i<L ; i++)
  11.     {
  12.         string s=q.substr(i,l);
  13.         sort(s.begin(),s.end());
  14.         if(p==s)
  15.         {
  16.             cout<<"Yes"<<"\n";
  17.             return;
  18.         }
  19.     }
  20.     cout<<"No"<<"\n";
  21.     return;
  22. }
  23.  
  24. int main()
  25. {
  26.     int tc;
  27.     cin>>tc;
  28.     while(tc-- > 0)
  29.     {
  30.         string str;
  31.         cin>>str;
  32.         string s;
  33.         cin>>s;
  34.  
  35.         solve(str,s);
  36.     }
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement