Kuro-orzz's Library

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

View on GitHub

:warning: Misc/Prefix_sum.cpp

Depends on

Code

#include "../template.h"

vector<vector<ll>> prefix_2d_init(int n, int m, const vector<vector<int>> &a) {
    vector<vector<ll>> pref(n+1, vector<ll>(m+1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + a[i-1][j-1];
        }
    }
    return pref;
}

ll get(const vector<vector<ll>> &pref, int a, int b, int c, int d) {
    return pref[c][d]-pref[c][b-1]-pref[a-1][d]+pref[a-1][b-1];
}
#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 2 "Misc/Prefix_sum.cpp"

vector<vector<ll>> prefix_2d_init(int n, int m, const vector<vector<int>> &a) {
    vector<vector<ll>> pref(n+1, vector<ll>(m+1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + a[i-1][j-1];
        }
    }
    return pref;
}

ll get(const vector<vector<ll>> &pref, int a, int b, int c, int d) {
    return pref[c][d]-pref[c][b-1]-pref[a-1][d]+pref[a-1][b-1];
}
Back to top page