Update include.hh
This commit is contained in:
parent
797b26f773
commit
2b916cdf13
14
include.hh
14
include.hh
|
@ -115,6 +115,20 @@ struct pair_hash {
|
||||||
#define adj(ch, n) __AS_PROCEDURE(vector<vector<int>> ch((n) + 1);)
|
#define adj(ch, n) __AS_PROCEDURE(vector<vector<int>> ch((n) + 1);)
|
||||||
#define edge(ch, u, v) __AS_PROCEDURE(ch[u].push_back(v), ch[v].push_back(u);)
|
#define edge(ch, u, v) __AS_PROCEDURE(ch[u].push_back(v), ch[v].push_back(u);)
|
||||||
#define Edge(ch, u, v) __AS_PROCEDURE(ch[u].push_back(v);)
|
#define Edge(ch, u, v) __AS_PROCEDURE(ch[u].push_back(v);)
|
||||||
|
template <typename T, typename Iterator> pair<size_t, map<T, size_t>> discretize(Iterator __first, Iterator __last) {
|
||||||
|
set<T> st(__first, __last);
|
||||||
|
size_t N = 0;
|
||||||
|
map<T, size_t> mp;
|
||||||
|
for (auto&& x : st) mp[x] = ++N;
|
||||||
|
return {N, mp};
|
||||||
|
}
|
||||||
|
template <typename T, typename Iterator> pair<size_t, unordered_map<T, size_t, safe_hash>> unordered_discretize(Iterator __first, Iterator __last) {
|
||||||
|
set<T> st(__first, __last);
|
||||||
|
size_t N = 0;
|
||||||
|
unordered_map<T, size_t, safe_hash> mp;
|
||||||
|
for (auto&& x : st) mp[x] = ++N;
|
||||||
|
return {N, mp};
|
||||||
|
}
|
||||||
|
|
||||||
/* io */
|
/* io */
|
||||||
#define untie __AS_PROCEDURE(ios_base::sync_with_stdio(0), cin.tie(NULL))
|
#define untie __AS_PROCEDURE(ios_base::sync_with_stdio(0), cin.tie(NULL))
|
||||||
|
|
Loading…
Reference in New Issue