1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const int MAXhx = 100237;
const int B1 = 1007;
const int B2 = 10009;
struct Hx {
vector<pair<Ele, int>> a[MAXhx + 10];
void Init() {
for (int i = 0; i < MAXhx; ++i) {
a[i].clear();
a[i].shrink_to_fit();
}
}
inline int& operator[](Ele v) {
int hxidx = (v.x * B1 % MAXhx + v.y * B2 % MAXhx) % MAXhx;
int i, topi = a[hxidx].size();
for (i = 0; i < topi; ++i) {
if (a[hxidx][i].first == v) {
break;
}
}
if (i < topi) return a[hxidx][i].second;
else {
a[hxidx].push_back(make_pair(v, 0));
return a[hxidx][topi].second;
}
}
};