Untitled

mail@pastecode.io avatar
unknown
plain_text
4 days ago
4.2 kB
2
Indexable
Never
#include <bits/stdc++.h>   //───▐▀▄──────▄▀▌───▄▄▄▄▄▄▄
#define ll long long       //───▌▒▒▀▄▄▄▄▀▒▒▐▄▀▀▒██▒██▒▀▀▄•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define f first            //──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define s second           //──▌▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define pb push_back       //▀█▒▒█▌▒▒█▒▒▐█▒▒▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▌•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define ub upper_bound     //▀▌▒▒▒▒▒▀▒▀▒▒▒▒▒▀▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐ ▄▄•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define lb lower_bound     //▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄█▒█•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define np next_permutation//▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█▀•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define us unordered_set   //──▐▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▌•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define cont continue     //────▀▄▄▀▀▀▀▄▄▀▀▀▀▀▀▄▄▀▀▀▀▀▀▄▄▀•.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯ •.,¸,.•*`•.,¸¸,.•*¯
#define IOS ios_base::sync_with_stdio(0),cin.tie(0)
#define INF INFINITY
#define ull unsigned long long
#define maxel(begin, end) *std::max_element(begin, end)
#define minel(begin, end) *std::min_element(begin, end)
using namespace std;
//*What if she's fine? *//
//*It's my mind that's wrong*//
//*And I just let bad thoughts*//
//*Linger for far too long*//
//*     Steve Lacy        *//
ll MAXN = 1e5;
vector<ll> t(4*MAXN,0);
ll const mod1 = 12345;
ll const mod2 = 23456;
vector<ll> a(4*MAXN,0);


void upd(ll v, ll tl, ll tr, ll p, ll x){
    if (tl==tr){
        t[v] = x;
        a[p] = x;
        return;
    }

    ll tm = (tl+tr)/2;

    if(p <= tm)
        upd(v*2, tl, tm, p,x);
    else
        upd(2*v+1, tm+1, tr, p, x);
    t[v] = t[v*2]+t[v*2+1];
}

ll get(ll v, ll tl, ll tr, ll l, ll r){
    if(l >r || tr < l || r < tl)
        return 0;

    if(l <= tl && tr <= r)
        return t[v];

    ll tm = (tl+tr)/2;

    return get(v * 2, tl, tm, l, r) + get(v * 2 + 1, tm + 1, tr, l, r);
}

int main() {
    //ifstream cin("sum.in");
    //ofstream cout("sum.out");

    for(ll n = 1; n < MAXN; n++){
        a[n] = (n%mod1*n%mod1)%mod1+(n%mod2*n%mod2*n%mod2)%mod2;
        upd(1,1,MAXN,n,a[n]);
    }

    ll k;

    cin >> k;

    while(k--){
        ll x,y;

        cin >> x >> y;
        if(x < 0){
            x = abs(x);
            upd(1, 1 , MAXN, x, y);
        }
        else{
            y++;
            cout << maxel(a.begin()+x, a.begin()+y) - minel(a.begin()+x, a.begin()+y) << endl;
        }
    }
    //cout<<  a[8] << ' ' << a[9];// /*  maxel(a.begin()+2, a.begin()+3);*/ minel(a.begin()+2, a.begin()+4);
    /*
    for(int i = 0; i < n; i++){
        cout << t[i] << ' ';
    }*/
}
/*int main() {
    IOS;
    int t =1;
    while(t--)
        solve();
    return 0;
}*/
/* Eratosphen's sieve formule
    bool was[MAXN+10];
    for(int i = 2; i*i <= MAXN; i++){
            if(!was[i]){
                for(int j = i*i; j <= MAXN; j+=i+i)
                    was[j]=true;
            }
    }
*/
Leave a Comment