例一
policija.in.1 -> policija1.in
policija.out.1 -> policija1.out
perl-rename 's/policija\.($\\w+)\.($\\d+)/policija$2.$1/' *例一
policija.in.1 -> policija1.in
policija.out.1 -> policija1.out
perl-rename 's/policija\.($\\w+)\.($\\d+)/policija$2.$1/' *Install the MSYS2 distribution.
Activate the clang64 environment. For newer versions of MSYS2, it is activated by default. If you have installed an older version, edit MSYS2_ROOT/etc/pacman.conf to activate it.
In the MSYS2 terminal, run pacman -S mingw-w64-clang-x86_64-clang.
Complie AND link your program with -fsanitize=address flag. See https://clang.llvm.org/docs/AddressSanitizer.html#id3 for more information. Note that you have to use the -fsanitize=address flag both when compiling and linking; for example, in CMakeLists.txt, you have to use both target_compile_options(<YOUR_TARGET> PRIVATE -fsanitize=address) and target_link_options(<YOUR_TARGET> PRIVATE -fsanitize=address).
| // This file presents some implementations of ndarray function/class. | |
| // Function | |
| // #1 | |
| template<typename T> T get_vector() { | |
| return T(); | |
| } | |
| template<typename T, int dimension, int... Dimensions> auto get_vector() { |
| using Point = pair<int,int>; | |
| ll cross(const Point& a, const Point& b) { | |
| return 1ll * a.first * b.second - 1ll * a.second * b.first; | |
| } | |
| // 逆时针 | |
| // 参考 mnbvmar 的写法:https://codeforces.com/contest/1284/submission/68178688 | |
| bool cmp_polar(const Point& a, const Point& b) { | |
| bool aorig = a.second > 0; | |
| bool borig = b.second > 0; | |
| if (aorig != borig) { |
| class SegSet { | |
| set<pii> s; | |
| public: | |
| // 插入闭区间[l,r] | |
| void insert(int l, int r) { | |
| auto iter = s.upper_bound({r, r}); | |
| while (iter != s.begin()) { | |
| // --a,++a 运算符的优先级低于 .,-> 运算符。 | |
| if ((--iter)->second < l) { | |
| break; |
| template<typename T,typename Compare> | |
| class MonoQueue { | |
| private: | |
| deque<pair<T,int>> que; | |
| Compare cmp; | |
| public: | |
| void push(const T& val, int i) { | |
| while (!que.empty() && !cmp(que.back().first, val)) { | |
| que.pop_back(); | |
| } |
| // 要求T具有<运算符 | |
| template <typename T> | |
| void sort_suffix(const T *s, int n, vector<int>& suf, vector<int>& h) { | |
| assert(SZ(suf) >= n && SZ(h) >= n); | |
| vector<int> rank(n); | |
| iota(all(suf), 0); | |
| sort(all(suf), [s](int x, int y) { return s[x] < s[y]; }); | |
| rank[suf[0]] = 0; | |
| for (int i = 1; i < n; ++i) { | |
| rank[suf[i]] = rank[suf[i - 1]] + (s[suf[i - 1]] < s[suf[i]]); |
| #ifdef _MSC_VER | |
| #include <intrin.h> | |
| static inline int __builtin_ctz(uint32_t x) { | |
| unsigned long ret; | |
| _BitScanForward(&ret, x); | |
| return (int)ret; | |
| } | |
| static inline int __builtin_ctzll(unsigned long long x) { |