struct myhash { int *s; ull *h,*qp; ll *p,len,*val; void init(vector<int> &path) { len=path.size(); for(int i=0;i<path.size();i++) { s[i+1]=path[i]; } h[0]=val[0]=0; qp[0]=p[0]=1; for(int i=1;i<=len;i++) { qp[i]=qp[i-1]*base; h[i]=h[i-1]*base+s[i]; } } ull get_hash(int l,int r) { return h[r]-h[l-1]*qp[r-l+1]; } myhash(int n) { s=new int[n]; h=new ull[n];qp=new ull[n]; p=new ll[n];val=new ll[n]; } ~myhash() { delete []s; delete []h;delete []qp; delete []p; delete []val; } };