kyopro_library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub dyktr06/kyopro_library

:warning: lib/others/zorbrist_hash.hpp

Code

#pragma once

#include <bits/stdc++.h>

using namespace std;

template <typename T>
struct ZorbristHash{
    map<T, int> rnd, cnt;
    int h = 0;

    ZorbristHash(){}

    void insert(T x){
        if(rnd.count(x) == 0){
            rnd[x] = rand();
        }
        if(cnt[x]) return;
        h ^= rnd[x];
        cnt[x]++;
    }

    void erase(T x){
        if(cnt[x] == 0) return;
        h ^= rnd[x];
        cnt[x]--;
    }

    int get(){
        return h;
    }
};
#line 2 "lib/others/zorbrist_hash.hpp"

#include <bits/stdc++.h>

using namespace std;

template <typename T>
struct ZorbristHash{
    map<T, int> rnd, cnt;
    int h = 0;

    ZorbristHash(){}

    void insert(T x){
        if(rnd.count(x) == 0){
            rnd[x] = rand();
        }
        if(cnt[x]) return;
        h ^= rnd[x];
        cnt[x]++;
    }

    void erase(T x){
        if(cnt[x] == 0) return;
        h ^= rnd[x];
        cnt[x]--;
    }

    int get(){
        return h;
    }
};
Back to top page