Advertisement
raihan02

URI 1911 Help Girafales

Dec 13th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. char s[200] , s1[200] , x[200] , x1[200] , s3[200];
  6. int tes;
  7.  
  8. while(cin >> tes)
  9. {
  10. if(tes == 0)
  11. break;
  12. map < string , string> ms;
  13. vector <string> vs , vc;
  14. for(int i = 0; i < tes; i++)
  15. {
  16. cin >> s >> s1;
  17.  
  18. ms[s] = s1;
  19. }
  20.  
  21. int p , t;
  22. cin >> p;
  23. t = p;
  24. while(p--)
  25. {
  26. cin >> x >> x1;
  27. vs.push_back(ms[x]);
  28. vc.push_back(x1);
  29.  
  30. }
  31. int ck = 0;
  32. for(int i = 0; i < vs.size(); i++)
  33. {
  34. int c = 0;
  35. for(int j = 0; j < vs[i].size(); j++)
  36. {
  37. if(vs[i][j] == vc[i][j])
  38. c++;
  39. }
  40.  
  41. if(c + 1 == vs[i].size() || c == vs[i].size())
  42. ck++;
  43.  
  44. }
  45. printf("%d\n",t - ck);
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement