Kuro-orzz's Library

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

View on GitHub

:warning: DataStructure/Point_set_range_composite.brute_force.cpp

Depends on

Code

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

#include "../template.h"

const int mod = 998244353;

vector<int> a, b;

int calc(int l, int r, int x) {
    if (l == r) return (1ll * a[l] * x + b[l]) % mod;
    return (1ll * a[r] * calc(l, r-1, x) + b[r]) % mod;
}

void solve() {
    int n, q; cin >> n >> q;
    a.resize(n);
    b.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    while (q--) {
        int tv; cin >> tv;
        if (tv == 0) {
            int p, c, d; cin >> p >> c >> d;
            a[p] = c;
            b[p] = d;
        } else {
            int l, r, x; cin >> l >> r >> x;
            cout << calc(l, r-1, x) << '\n';
        }
    }
}
#line 1 "DataStructure/Point_set_range_composite.brute_force.cpp"
// #define PROBLEM "https://judge.yosupo.jp/problem/point_set_range_composite"

#line 2 "template.h"

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define MOD (ll)(1e9+7)
#define all(x) (x).begin(),(x).end()
#define unique(x) x.erase(unique(all(x)), x.end())
#define INF32 ((1ull<<31)-1)
#define INF64 ((1ull<<63)-1)
#define inf (ll)1e18

#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

const int mod = 998244353;

void solve();

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    // cin.exceptions(cin.failbit);
    // int t; cin >> t;
    // while(t--)
        solve();
    cerr << "\nTime run: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << '\n';
    return 0;
}
#line 4 "DataStructure/Point_set_range_composite.brute_force.cpp"

const int mod = 998244353;

vector<int> a, b;

int calc(int l, int r, int x) {
    if (l == r) return (1ll * a[l] * x + b[l]) % mod;
    return (1ll * a[r] * calc(l, r-1, x) + b[r]) % mod;
}

void solve() {
    int n, q; cin >> n >> q;
    a.resize(n);
    b.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    while (q--) {
        int tv; cin >> tv;
        if (tv == 0) {
            int p, c, d; cin >> p >> c >> d;
            a[p] = c;
            b[p] = d;
        } else {
            int l, r, x; cin >> l >> r >> x;
            cout << calc(l, r-1, x) << '\n';
        }
    }
}
Back to top page