回文自动机  马拉车 后缀自动机  后缀数组  AC自动机  EXKMP  KMP  字典树  字符串匹配shiftand算法  字符串哈希   

 手写哈希

#include<bits/stdc++.h>
using namespace std;
struct Hash {
    static const int MOD = 1999997;
    static const int N = 1e6;
    int head[MOD + 10], nx[N], top;
    int hs[N], id[N];
    void init() {
        memset(head, -1, sizeof head);
        top = 0;
    }
    void insert(int x, int y) {
        int k = x % MOD;
        hs[top] = x; id[top] = y; nx[top] = head[k]; head[k] = top++;
    }
    int find(int x) {
        int k = x % MOD;
        for (int i = head[k]; i != -1; i = nx[i]) {
            if (hs[i] == x) {
                return id[i];
            }
        }
        return -1;
    }
}hs;
int main(){   }

hash
View Code

相关文章:

  • 2021-12-25
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
猜你喜欢
  • 2021-07-05
  • 2021-07-07
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
相关资源
相似解决方案