字符串哈希
//题目:好文章(双哈希。。学长是x哈希) #include#include #include #include #include #include
树哈希
//地铁问题(树哈希的板题???) #include#include #include #include #include #include #define ll long long#define ull unsigned long long#define base 7397#define P 1000000007using namespace std;char A[3005],B[3005];ull Hash(char *p,int st,int en){ int cnt=0,pos=st+1,ans=131; vector tmp; for(int i=st;i<=en;i++) { if(p[i]=='0')cnt++; else cnt--; if(!cnt){ tmp.push_back(Hash(p,pos,i-1)); pos=i+2; } } sort(tmp.begin(),tmp.end()); for(int i=0;i