Guest User

Untitled

a guest
Oct 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define FAST ios_base::sync_with_stdio(0);cin.tie(0);
  6.  
  7. int main()
  8. {
  9. FAST;
  10. int T;
  11. cin >> T;
  12.  
  13. int i, j;
  14. for(i = 1; i <= T; i++)
  15. {
  16. int L;
  17. string A;
  18. string B;
  19. int Result = 0;
  20.  
  21. cin >> L;
  22. cin >> A;
  23. cin >> B;
  24.  
  25. for(i = 1; i <= L; i++)
  26. {
  27. unordered_set<string> Set;
  28.  
  29. for(j = 0; (i + j) <= L; j++)
  30. {
  31. string Temp = B.substr(j, i);
  32.  
  33. sort(Temp.begin(), Temp.end());
  34. Set.insert(Temp);
  35. }
  36.  
  37. for(j = 0; (i + j) <= L; j++)
  38. {
  39. string Temp = A.substr(j, i);
  40.  
  41. sort(Temp.begin(), Temp.end());
  42.  
  43. if(Set.count(Temp))
  44. {
  45. Result++;
  46. }
  47. }
  48. }
  49.  
  50. cout << "Case #" << i << ": " << Result << endl;
  51. }
  52.  
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment