const int mod1=998244353,mod2=3079;
struct Hasher{
int x,y;
inline Hasher(int X, int Y):x(X),y(Y){}
friend inline bool operator <(const Hasher &A, const Hasher &B){
A.x!=B.x?A.x<B.x:A.y<B.y;
}
friend inline Hasher operator +(const Hasher &A, const Hasher &B){
return Hasher((A.x+B.x)%mod1,(A.y+B.y)%mod2);
}
friend inline Hasher operator -(const Hasher &A, const Hasher &B){
return Hasher((A.x-B.x+mod1)%mod1,(A.y-B.y+mod2)%mod2);
}
friend inline Hasher operator *(const Hasher &A, const Hasher &B){
return Hasher(1LL*A.x*B.x%mod1,1LL*A.y*B.y%mod2);
}
};
set<Hasher>rst;
const Hasher seed=Hasher(31,131);
双哈希模板
于 2024-05-15 09:03:37 首次发布