Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- int t;
- set <string> S;
- void Fix(string &s)
- {
- if (s.size() > 2) sort(s.begin() + 1, s.end() - 1);
- }
- int main()
- {
- scanf("%d", &t);
- for (int tc = 1; tc <= t; tc++) {
- int n, m; scanf("%d %d", &n, &m);
- S.clear();
- string s;
- for (int i = 0; i < n; i++) {
- cin >> s; Fix(s);
- S.insert(s);
- }
- printf("Case #%d: ", tc);
- for (int i = 0; i < m; i++) {
- cin >> s; Fix(s);
- printf("%d", S.count(s));
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement