Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <vector>
- #include <map>
- #include <math.h>
- #define pb push_back
- #define F first
- #define S second
- #define ll long long
- #define pii pair<int, int>
- #define pll pair<ll, ll>
- using namespace std;
- const ll MAX = 1e9;
- const ll MOD = 1e9 + 7;
- ll binpow(ll a, ll b)
- {
- ll res = 1;
- while (b)
- {
- if (b & 1)
- res = res * a % MOD;
- a = a * a % MOD;
- b >>= 1;
- }
- return res;
- }
- bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
- {
- return (a.second < b.second);
- }
- int get_size(int x)
- {
- int bit_size = 0;
- while (x != 0)
- {
- x >>= 1;
- bit_size++;
- }
- return bit_size;
- }
- ll lcm(ll a, ll b)
- {
- return (ll)((a / __gcd(a, b)) * b);
- }
- void NonSense()
- {
- int64_t n, q;
- cin >> n >> q;
- vector<int64_t> A(n+1000);
- for (int i = 1; i <= n; i++)
- cin >> A[i];
- int64_t l, r, x, p;
- while (q--)
- {
- int64_t type;
- cin >> type;
- switch (type)
- {
- case 1:
- {
- cin >> l >> r >> x;
- for (int64_t i = l; i < r; i++)
- A[i] = x;
- break;
- }
- case 2:
- {
- cin >> l >> r >> x;
- for (int64_t i =l; i <= r; i++)
- A[i] = (i-l+1)* x;
- break;
- }
- case 3:
- {
- cin >> p >> x;
- A.insert(A.begin() + p + 1 , x);
- break;
- }
- case 4:
- {
- cin >> l >> r;
- int64_t sum = 0;
- for (int64_t i = l; i <= r; i++)
- sum += A[i];
- cout << "\t\t" << sum << endl;
- break;
- }
- }
- }
- }
- int main()
- {
- ios::sync_with_stdio(0);
- int T;
- cin >> T;
- for (; T--;)
- {
- NonSense();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement