algo

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub dnx04/algo

:x: data-structure/test/Range_Affine_Range_Sum.test.cpp

Code

#define PROBLEM "https://judge.yosupo.jp/problem/range_affine_range_sum"

#include <bits/extc++.h>

using namespace std;

#include "data-structure/lazy_segtree.hpp"
#include "utility/static_modulo.hpp"

using Fp = static_modulo<998244353>;

struct S {
  Fp a;
  int size;
};
struct F {
  Fp a, b;
};
S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }
S e() { return S{0, 0}; }
S mapping(F l, S r) { return S{r.a * l.a + l.b * r.size, r.size}; }
F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }
F id() { return F{1, 0}; }

int main() {
  int n, q;
  cin >> n >> q;
  vector<S> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = S{x, 1};
  }
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 0) {
      int l, r;
      int c, d;
      cin >> l >> r >> c >> d;
      seg.apply(l, r, F{c, d});
    } else {
      int l, r;
      cin >> l >> r;
      cout << seg.prod(l, r).a << '\n';
    }
  }
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.4/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: utility/static_modulo.hpp: line -1: no such header
Back to top page