Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define FAST ios_base::sync_with_stdio(0);cin.tie(0);
- int main()
- {
- FAST;
- int T;
- cin >> T;
- int i, j;
- for(i = 1; i <= T; i++)
- {
- int L;
- string A;
- string B;
- int Result = 0;
- cin >> L;
- cin >> A;
- cin >> B;
- for(i = 1; i <= L; i++)
- {
- unordered_set<string> Set;
- for(j = 0; (i + j) <= L; j++)
- {
- string Temp = B.substr(j, i);
- sort(Temp.begin(), Temp.end());
- Set.insert(Temp);
- }
- for(j = 0; (i + j) <= L; j++)
- {
- string Temp = A.substr(j, i);
- sort(Temp.begin(), Temp.end());
- if(Set.count(Temp))
- {
- Result++;
- }
- }
- }
- cout << "Case #" << i << ": " << Result << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment