Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <set>
- #define nmax 100005
- #define kmax 15
- #define sigma 26
- #include <unordered_set>
- #include <string>
- using namespace std;
- string s[nmax],p[nmax],pcopy[nmax];
- int l[kmax];
- int n,m,k,q;
- long long pnr[nmax];
- unordered_set <long long> my_set;
- long long int make_number(string p)
- {
- long long int ret=0;
- for(int i=k-1;i>=0;--i)
- ret=ret*sigma+p[i]-'a';
- return ret;
- }
- int main()
- {
- int cntmax=-1,sol=0;
- ifstream f("cripto1.in");
- f>>n>>m>>k>>q;
- for(int i=1;i<=n;++i) /// Citesc limbajul
- f>>s[i],my_set.insert(make_number(s[i]));
- for(int i=1;i<=m;++i) /// Citesc cuvintele
- f>>p[i],pnr[i]=make_number(p[i]);
- for(int i=1;i<=q;++i)
- {
- int cnt=0;
- long long hash_number=0;
- for(int j=0;j<k;++j)
- f>>l[j];
- for(int j=k-1;j>=0;--j)
- hash_number=hash_number*sigma+l[j];
- for(int j=1;j<=m;++j)
- if(my_set.find(pnr[j]+hash_number)!=my_set.end())
- ++cnt;
- if(cnt>cntmax)
- cntmax=cnt,sol=i;
- }
- ofstream g("cripto1.out");
- g<<sol<<' '<<cntmax<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement