Advertisement
Guest User

Untitled

a guest
Sep 29th, 2014
570
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <set>
  4. #include <string>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int t;
  9. set <string> S;
  10.  
  11. void Fix(string &s)
  12. {
  13.     if (s.size() > 2) sort(s.begin() + 1, s.end() - 1);
  14. }
  15.  
  16. int main()
  17. {
  18.     scanf("%d", &t);
  19.     for (int tc = 1; tc <= t; tc++) {
  20.         int n, m; scanf("%d %d", &n, &m);
  21.         S.clear();
  22.         string s;
  23.         for (int i = 0; i < n; i++) {
  24.             cin >> s; Fix(s);
  25.             S.insert(s);
  26.         }
  27.         printf("Case #%d: ", tc);
  28.         for (int i = 0; i < m; i++) {
  29.             cin >> s; Fix(s);
  30.             printf("%d", S.count(s));
  31.         }
  32.         printf("\n");
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement