SHARE
TWEET

Untitled

a guest Mar 26th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #define PLEC fin.close(); fout.close(); return 0;
  3. using namespace std;
  4. ifstream fin("cripto.in");
  5. ofstream fout("cripto.out");
  6. unordered_set<int64_t> S;
  7. int n, m, k, q, curr, res(-1), ind, t;
  8. int64_t Hash, aux;
  9. string s;
  10. inline int64_t make_number(string p)
  11. {
  12.     int64_t r(0);
  13.     for (int i  = k - 1; i >= 0; i--)
  14.         r = r * 26 + p[i] - 'a';
  15.     return r;
  16. }
  17. int main()
  18. {
  19.     fin >> n >> m >> k >> q;
  20.     for (int i = 1; i <= n; ++i)
  21.     {
  22.         fin >> s;
  23.         Hash = make_number(s);
  24.         S.insert(Hash);
  25.     }
  26.     vector<int64_t> v(m + 1);
  27.     for (int i = 1; i <= m; ++i)
  28.     {
  29.         fin >> s;
  30.         v[i] = make_number(s);
  31.     }
  32.     vector<int> op(k + 1);
  33.     for (int i = 1; i <= q; ++i)
  34.     {
  35.         Hash = curr = 0;
  36.         for (int j = 0; j < k; ++j)
  37.             fin >> op[j];
  38.         for (int j = k - 1; j >= 0; --j)
  39.             Hash = Hash * 26 + op[j];
  40.         for (int j = 1; j <= m; ++j)
  41.             curr += (S.find(Hash + v[j]) != S.end());
  42.         if (curr > res)
  43.             res = curr, ind = i;
  44.     }
  45.     fout << ind << ' ' << res;
  46.     PLEC
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top