Advertisement
informaticage

Matteo spam filter OII

Mar 31st, 2021
1,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int solve(vector<string> good, vector<string> bad, vector<string> words) {
  8.   int gfound = 0, bfound = 0;
  9.   for (string w : words) {
  10.     if (find(good.begin(), good.end(), w) != good.end()) {
  11.       gfound++;
  12.     }
  13.  
  14.     if (find(bad.begin(), bad.end(), w) != bad.end()) {
  15.       bfound++;
  16.     }
  17.   }
  18.  
  19.   if (gfound && !bfound)
  20.     return 1;
  21.   if (bfound && !gfound)
  22.     return 2;
  23.   return 3;
  24. }
  25.  
  26. int main() {
  27.   int B, G;
  28.   cin >> B;
  29.   vector<string> bad(B);
  30.   for (string &b : bad) {
  31.     cin >> b;
  32.   }
  33.  
  34.   cin >> G;
  35.   vector<string> good(G);
  36.   for (string &g : good) {
  37.     cin >> g;
  38.   }
  39.  
  40.   int E;
  41.   cin >> E;
  42.  
  43.   int good_found = 0, bad_found = 0;
  44.   for (int i = 0; i < E; i++) {
  45.     // For each email
  46.     int W;
  47.     cin >> W;
  48.     vector<string> words(W);
  49.     for (string &w : words) {
  50.       cin >> w;
  51.     }
  52.  
  53.     switch (solve(good, bad, words)) {
  54.     case 1:
  55.       good_found++;
  56.       break;
  57.     case 2:
  58.       bad_found++;
  59.       break;
  60.     }
  61.   }
  62.  
  63.   cout << bad_found << " " << good_found;
  64.   return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement