From 2333a23577f0909e8269ed59c7c323b8d3217da1 Mon Sep 17 00:00:00 2001 From: Ariel Date: Tue, 16 Jan 2024 15:52:21 +0800 Subject: [PATCH] Update include.hh --- include.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include.hh b/include.hh index f573afe..6b334ee 100644 --- a/include.hh +++ b/include.hh @@ -6,6 +6,7 @@ using namespace std; #define __DECOMPOSE_N(a, ...) auto [__VA_ARGS__] = a; constexpr void __() {} #define __AS_PROCEDURE(...) __(); __VA_ARGS__; __() +#define __as_typeof(container) decltype(container)::value_type using ll = int64_t; using ull = uint64_t; @@ -49,6 +50,8 @@ struct igt { } }; +#define unordered_counter(from, to) __AS_PROCEDURE(unordered_map<__as_typeof(from), size_t> to; for (auto&& x : from) ++to[x];) +#define counter(from, to, cmp) __AS_PROCEDURE(map<__as_typeof(from), size_t, cmp> to; for (auto&& x : from) ++to[x];) #define untie __AS_PROCEDURE(ios_base::sync_with_stdio(0), cin.tie(NULL)) template void __read(T& x) { cin >> x; } template void __read(T& x, U&... args) { cin >> x; __read(args...); }