1
0
Fork 0

Update include.hh

This commit is contained in:
Ariel 2024-03-03 11:50:10 +08:00 committed by GitHub
parent 797b26f773
commit 2b916cdf13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -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))