CSES - Range Update Queries
Authors: Benjamin Qi, Óscar Garries
Appears In
Can convert any point update range query -> range update point query. Here we use a segment tree; a BIT would also work.
Implementation without template:
#include <bits/stdc++.h>using namespace std;using ll = long long;using ld = long double;template<class T> struct Seg {int n;T ID = 0;vector<T> seg;
Implementation with template:
#include <bits/stdc++.h>using namespace std;using ll = long long;using ld = long double;using db = double;using str = string; // yay python!using pi = pair<int,int>;using pl = pair<ll,ll>;
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!