正文
增加 27 行删除 27 行
387 行未改动全部展开3883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494 行未改动45445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049118 行未改动51051151251351451551651751818 行未改动53753853954054154254354454554654754854955055155255355427 行未改动387 行未改动全部展开#include <bit>#endifnamespace atcoder {namespace internal {#if __cplusplus >= 202002Lusing std::bit_ceil;#elseunsigned int bit_ceil(unsigned int n) {unsigned int x = 1;while (x < (unsigned int)(n)) x *= 2;return x;}#endifint countr_zero(unsigned int n) {#ifdef _MSC_VERunsigned long index;_BitScanForward(&index, n);return index;#elsereturn __builtin_ctz(n);#endif}constexpr int countr_zero_constexpr(unsigned int n) {int x = 0;while (!(n & (1 << x))) x++;return x;}} // namespace internal} // namespace atcodernamespace atcoder {#if __cplusplus >= 201703Ltemplate <class S, auto op, auto e> struct segtree {static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,"op must work as S(S, S)");static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,"e must work as S()");#elsetemplate <class S, S (*op)(S, S), S (*e)()> struct segtree {#endifpublic:segtree() : segtree(0) {}explicit segtree(int n) : segtree(std::vector<S>(n, e())) {}explicit segtree(const std::vector<S>& v) : _n(int(v.size())) {4 行未改动for (int i = size - 1; i >= 1; i--) {update(i);}}void set(int p, S x) {assert(0 <= p && p < _n);p += size;d[p] = x;for (int i = 1; i <= log; i++) update(p >> i);}S get(int p) const {assert(0 <= p && p < _n);return d[p + size];}S prod(int l, int r) const {assert(0 <= l && l <= r && r <= _n);S sml = e(), smr = e();l += size;r += size;while (l < r) {if (l & 1) sml = op(sml, d[l++]);if (r & 1) smr = op(d[--r], smr);l >>= 1;r >>= 1;}return op(sml, smr);}S all_prod() const { return d[1]; }template <bool (*f)(S)> int max_right(int l) const {return max_right(l, [](S x) { return f(x); });}template <class F> int max_right(int l, F f) const {18 行未改动l++;} while ((l & -l) != l);return _n;}template <bool (*f)(S)> int min_left(int r) const {return min_left(r, [](S x) { return f(x); });}template <class F> int min_left(int r, F f) const {18 行未改动sm = op(d[r], sm);} while ((r & -r) != r);return 0;}private:int _n, size, log;std::vector<S> d;void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }};} // namespace atcoder#include<bits/stdc++.h>#define int long longusing namespace std;using namespace atcoder;27 行未改动387 行未改动全部展开3883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494 行未改动45445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049118 行未改动51051151251351451551651751818 行未改动53753853954054154254354454554654754854955055155255355427 行未改动387 行未改动全部展开#include <bit>#endifnamespace atcoder {namespace internal {#if __cplusplus >= 202002Lusing std::bit_ceil;#elseunsigned int bit_ceil(unsigned int n) {unsigned int x = 1;while (x < (unsigned int)(n)) x *= 2;return x;}#endifint countr_zero(unsigned int n) {#ifdef _MSC_VERunsigned long index;_BitScanForward(&index, n);return index;#elsereturn __builtin_ctz(n);#endif}constexpr int countr_zero_constexpr(unsigned int n) {int x = 0;while (!(n & (1 << x))) x++;return x;}} // namespace internal} // namespace atcodernamespace atcoder {#if __cplusplus >= 201703Ltemplate <class S, auto op, auto e> struct segtree {static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,"op must work as S(S, S)");static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,"e must work as S()");#elsetemplate <class S, S (*op)(S, S), S (*e)()> struct segtree {#endifpublic:segtree() : segtree(0) {}explicit segtree(int n) : segtree(std::vector<S>(n, e())) {}explicit segtree(const std::vector<S>& v) : _n(int(v.size())) {4 行未改动for (int i = size - 1; i >= 1; i--) {update(i);}}void set(int p, S x) {assert(0 <= p && p < _n);p += size;d[p] = x;for (int i = 1; i <= log; i++) update(p >> i);}S get(int p) const {assert(0 <= p && p < _n);return d[p + size];}S prod(int l, int r) const {assert(0 <= l && l <= r && r <= _n);S sml = e(), smr = e();l += size;r += size;while (l < r) {if (l & 1) sml = op(sml, d[l++]);if (r & 1) smr = op(d[--r], smr);l >>= 1;r >>= 1;}return op(sml, smr);}S all_prod() const { return d[1]; }template <bool (*f)(S)> int max_right(int l) const {return max_right(l, [](S x) { return f(x); });}template <class F> int max_right(int l, F f) const {18 行未改动l++;} while ((l & -l) != l);return _n;}template <bool (*f)(S)> int min_left(int r) const {return min_left(r, [](S x) { return f(x); });}template <class F> int min_left(int r, F f) const {18 行未改动sm = op(d[r], sm);} while ((r & -r) != r);return 0;}private:int _n, size, log;std::vector<S> d;void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }};} // namespace atcoder#include<bits/stdc++.h>#define int long longusing namespace std;using namespace atcoder;27 行未改动