Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- map< string, int > mp;
- int main(){
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t, cs = 0;
- cin >> t;
- while(t--){
- cout << "Case " << ++cs << ":\n";
- mp.clear();
- int n;
- cin >> n;
- for(int i=0; i<n; i++){
- string s;
- cin >> s;
- if(s.size() > 2) sort(s.begin()+1, s.end()-1);
- //cout << s << '\n';
- mp[s]++;
- }
- int q;
- cin >> q;
- getchar();
- for(int i=0; i<q; i++){
- string line, s;
- getline(cin, line);
- long long ans = 1;
- stringstream ss(line);
- while(ss >> s){
- if(s.size() > 2) sort(s.begin()+1, s.end()-1);
- //cout << s << '\n';
- ans *= mp[s];
- }
- cout << ans << '\n';
- }
- }
- #ifdef ERFANUL007
- fprintf(stderr, ">>> Runtime : %.9f\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement