Guest User

Untitled

a guest
Aug 5th, 2019
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma warning(disable:4786)
  2. #pragma warning(disable:4996)
  3. #include<bits/stdc++.h>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/trie_policy.hpp>
  6. #include<ext/pb_ds/detail/standard_policies.hpp>
  7. #define pii pair<int,int>
  8. #define pll pair<long long ,long long>
  9. #define pli pair<long long , int>
  10. #define pil pair<int ,long long>
  11. #define pi acos(-1)
  12. #define pb push_back
  13. #define mkp make_pair
  14. #define all(a) a.begin(), a.end()
  15. #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  16. #define ll long long
  17. #define MAX 300005
  18. #define INF 0x3f3f3f3f
  19. template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
  20. template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);} // M is prime}
  21.  
  22. using namespace std;
  23. using namespace __gnu_pbds;
  24.  
  25. typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
  26. typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
  27. typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
  28.  
  29.  
  30.  
  31.  
  32. int main(){
  33. IOS
  34. //freopen("output.txt","w",stdout);
  35. int n,q;
  36. cin>>n>>q;
  37. pref_trie t;
  38. for(int i=0;i<n;i++){
  39. string s;
  40. cin>>s;
  41. t.insert(s);
  42. }
  43. for(int i=0;i<q;i++){
  44. string s;
  45. cin>>s;
  46. auto output = t.prefix_range(s);
  47. int count=0;
  48. for(auto it=output.first;it!=output.second;it++)count++;
  49. cout<<count<<"\n";
  50. }
  51. }
RAW Paste Data