引自tourist的哈希板子,引入和时间相关的随机值mt19937_64,所以不会被卡掉
入参:传入string
使用:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long ll;
typedef double db;
typedef pair<ll,int> P;
#define fi first
#define se second
#define pb push_back
#define dbg(x) cerr<<(#x)<<":"<<x<<" ";
#define dbg2(x) cerr<<(#x)<<":"<<x<<endl;
#define SZ(a) (int)(a.size())
#define sci(a) scanf("%d",&(a))
#define scll(a) scanf("%lld",&(a))
#define pt(a) printf("%d",a);
#define pte(a) printf("%d\n",a)
#define ptlle(a) printf("%lld\n",a)
#define debug(...) fprintf(stderr, __VA_ARGS__)
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
struct hash61 {
static const uint64_t md = (1LL << 61) - 1;
static uint64_t step;
static vector<uint64_t> pw;
uint64_

本文介绍了如何在C++中使用mt19937_64生成时间相关的随机数,结合hash61结构体实现一个哈希函数,用于处理字符串范围内的哈希计算。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



