Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef long long ll;
- const int size = (1 << 23);
- struct hashMap{
- long long H[size + 7] = {};
- int R[size + 7] = {};
- long long mHash(int a, int b){
- return a * 1000000ll + b + 1;
- }
- int count(int v, int r){
- ll g = mHash(v, r);
- ll h = g & (size - 1);
- while(1){
- if(H[h] == 0){
- return 0;
- }
- if(H[h] == g){
- return 1;
- }
- h++;
- if(h == size){
- h = 0;
- }
- }
- return 1;
- }
- int &operator[](pair<int, int> T){
- ll g = mHash(T.first, T.second);
- ll h = g & (size - 1);
- while(1){
- if(H[h] == 0 || H[h] == g){
- H[h] = g;
- return R[h];
- }
- h++;
- if(h == size){
- h = 0;
- }
- }
- }
- };
Add Comment
Please, Sign In to add comment