#include <iostream>
#include <algorithm>
using namespace std;
const int mod=10000003;
int n,t,q,s[100001],a[100001],len[100001],h[100001],m,r,ht;
long long qz[100001];
inline int _hash(int len){
int ans=0;
for(int i=1;i<=len;i++){
ans=(1ll*ans+1ll*h[i]*i%mod)%mod;
}
return ans;
}
int main(void){
scanf("%d%d%d",&n,&t,&q);
for(int i=1;i<=t;i++){
scanf("%d",&h[i]);
}
ht=_hash(t);
for(int i=1;i<=n;i++){
scanf("%d",&len[i]);
for(int j=1;j<=len[i];j++){
scanf("%d",&h[j]);
}
a[i]=_hash(len[i]);
}
scanf("%d",&m);
for(int i=1;i<=m;i++){
scanf("%d",&r);
qz[i]=qz[i-1]+a[r];
int x=lower_bound(qz,qz+1+i,qz[i]-ht)-qz;
if(qz[i]-qz[x]==ht){
printf("%d",i);
return 0;
}
}
}
这是我的代码,hash 函数有些问题。
那么问一下各位 dalao,这题的 hash 应该如何写呢?