pb_ds 的 hash_table 如何存储 pair<int,int>

#include"bits/stdc++.h"
#undef _GLIBCXX_HAVE_ICONV
#include"bits/extc++.h"
using namespace std;
using namespace __gnu_pbds;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int Rd[2001];
struct pair_hash{
	const int S = 2e9;
	size_t operator ()(const pair<int,int>&p)const{
		return 1ll*p.first*S+p.second;
	}
};
cc_hash_table<pair<int,int>,int,pair_hash>Mp;
int main(){
	for(int i=1;i<=2000;i++)Rd[i]=rnd();
	for(int i=1;i<=2000;i++)
		for(int j=1;j<=2000;j++)
			Mp[{Rd[i],Rd[j]}]=i+j;
	cerr<<1.0*clock()/CLOCKS_PER_SEC<<'\n';
}

posted @ 2025-05-31 19:31  Undead2008  阅读(125)  评论(0)    收藏  举报