lalalalalalalaalalla

Untitled

Jun 5th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <ostream>
  4. #include <istream>
  5. #include <set>
  6. #include <unordered_set>
  7. #include <map>
  8. #include <unordered_map>
  9. #include <bitset>
  10. #include <vector>
  11. #include <string>
  12. #include <stack>
  13. #include <queue>
  14. #include <deque>
  15. #include <array>
  16. #include <algorithm>
  17. #include <functional>
  18. #include <cmath>
  19. #include <time.h>
  20. #include <random>
  21. #include <chrono>
  22. #include <cassert>
  23. #include <cstring>
  24. #include <limits>
  25.  
  26. using namespace std;
  27.  
  28. #define int long long
  29. #define pb push_back
  30. #define ppb pop_back
  31. #define all(a) (a).begin(), (a).end()
  32. #define pii pair<int, int>
  33. #define ld long double
  34.  
  35. istream& operator>> (istream& in, pii& b) {
  36. in >> b.first >> b.second;
  37. return in;
  38. }
  39.  
  40. ostream& operator<< (ostream& out, const pii& b) {
  41. out << "{" << b.first << ", " << b.second << "}";
  42. return out;
  43. }
  44.  
  45. template<typename T> ostream& operator<< (ostream& out, const vector<T>& a) {
  46. for (auto k : a) out << k << " ";
  47. return out;
  48. }
  49.  
  50. template <typename T1, typename T2> inline bool chkmin(T1 &x, const T2 &y) {if (x > y) {x = y; return 1;} return 0;}
  51. template <typename T1, typename T2> inline bool chkmax(T1 &x, const T2 &y) {if (x < y) {x = y; return 1;} return 0;}
  52.  
  53. #ifdef LOCAL
  54. #define dbg(x) cout << #x << " : " << (x) << endl;
  55. const long long INF = 1e18;
  56. // const long long mod = 2600000069;
  57. // const long long p = 10;
  58. #else
  59. #define dbg(x) 57
  60. const long long INF = 1e18;
  61. // const long long mod = 2600000069;
  62. // const long long p = 179;
  63. #endif
  64.  
  65. const ld PI = 4 * atan(1);
  66.  
  67. #define time clock() / (double) CLOCKS_PER_SEC
  68.  
  69. // #pragma GCC optimize("Ofast,no-stack-protector")
  70. // #pragma GCC target("sse,sse2,sse3,sse3,sse4")
  71. // #pragma GCC optimize("unroll-loops")
  72. // #pragma GCC optimize("fast-math")
  73. // #pragma GCC target("avx2")
  74.  
  75. mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
  76.  
  77. string lower(string s) {
  78. int sz = s.size();
  79. for (int i = 0; i < sz; i++) {
  80. if ('A' <= s[i] && s[i] <= 'Z') {
  81. s[i] = s[i] - 'A' + 'a';
  82. }
  83. }
  84. return s;
  85. }
  86.  
  87. int count(string s) {
  88. int sz = s.size();
  89. int ans = 0;
  90. for (int i = 0; i < sz; i++) {
  91. if ('A' <= s[i] && s[i] <= 'Z') {
  92. ans++;
  93. }
  94. }
  95. return ans;
  96. }
  97.  
  98. map<string, vector<string>> have;
  99.  
  100. bool bad(string s) {
  101. if (count(s) != 1) return 1;
  102. string ls = lower(s);
  103. if (have.find(ls) == have.end()) return 0;
  104. return find(have[ls].begin(), have[ls].end(), s) == have[ls].end();
  105. }
  106.  
  107. signed main() {
  108. ios_base::sync_with_stdio(0);
  109. cin.tie(0);
  110. cout.tie(0);
  111. int n;
  112. cin >> n;
  113. for (int i = 0; i < n; i++) {
  114. string s;
  115. cin >> s;
  116. int sz = s.size();
  117. have[lower(s)].pb(s);
  118. }
  119. string s;
  120. getline(cin, s);
  121. getline(cin, s);
  122. int ans = 0;
  123. string cur;
  124. for (auto c : s) {
  125. if (c == ' ') {
  126. if (!cur.empty()) {
  127. ans += bad(cur);
  128. }
  129. cur.clear();
  130. } else {
  131. cur.pb(c);
  132. }
  133. }
  134. if (!cur.empty()) {
  135. ans += bad(cur);
  136. }
  137. cout << ans << "\n";
  138. }
  139. /*
  140.  
  141. */
  142.  
Advertisement
Add Comment
Please, Sign In to add comment