SHARE
TWEET

e289

Emiliatan Jul 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* e289              */
  2. /* AC (0.2s, 64.6MB) */
  3. #pragma warning( disable : 4996 )
  4. #include <iostream>
  5. #include <string>
  6. #include <unordered_map>
  7.  
  8. using namespace std;
  9.  
  10. unordered_map <string, long long> umap;
  11. long long n, m, l = 0, r = 0, cata = 0, ans = 0;
  12. string s[200001];
  13.  
  14. int main()
  15. {
  16.     ios_base::sync_with_stdio(false);
  17.     cin.tie(0); cout.tie(0);
  18.  
  19.     cin >> m >> n;
  20.     for (int i = 0; i < n && cin >> s[i]; ++i);
  21.  
  22.     for (int i = 0; i < m; ++i)
  23.     {
  24.         if (!umap[s[i]])
  25.             ++cata;
  26.         ++umap[s[i]];
  27.     }
  28.  
  29.     l = 0, r = m;
  30.     for (; r <= n;)
  31.     {
  32.         ans += (m == cata);
  33.  
  34.         if (--umap[s[l]] == 0)
  35.             --cata;
  36.  
  37.         if (umap[s[r]]++ == 0)
  38.             ++cata;
  39.  
  40.         ++l, ++r;
  41.     }
  42.     cout << ans;
  43.     return 0;
  44. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top