Submission #32574131


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
const ll mod=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)


ll R=(mod+1)/2;
struct lazy_S {
    ll E;
    ll F;
    ll size;
};

using lazy_F = ll;

lazy_S lazy_op(lazy_S l, lazy_S r) {
    return lazy_S{
        (l.E+r.E+(l.F*r.size)%mod)%mod,(l.F+r.F)%mod,l.size+r.size
    };
}

lazy_S lazy_e() { return lazy_S{0, 0, 0}; }

lazy_S mapping(lazy_F l, lazy_S r) {
    l%=mod;
    if(l==0) return r;
    ll tmp=(r.size*(r.size+1))%mod;
    tmp*=(l*R)%mod;
    tmp%=mod;
    return lazy_S{
        (r.E+tmp)%mod,(r.F+(l*r.size)%mod)%mod,r.size
    };
}

//l(r(x))
lazy_F composition(lazy_F l, lazy_F r) {
    return (l+r)%mod;
}

lazy_F lazy_id(){return 0;}

#define lazy_calc lazy_S,lazy_op,lazy_e,lazy_F,mapping,composition,lazy_id


void solve();
// oddloop
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t=1;
    //cin>>t;
    rep(i,t) solve();
}

void solve(){
    int N,Q;
    cin>>N>>Q;
    lazy_segtree<lazy_calc> seg(N);
    vector<ll> A(N);
    rep(i,N) seg.set(i,{0,0,1});
    rep(i,N){
        ll a;
        cin>>a;
        A[i]=a;
        seg.apply(i,N,a);
    }
    rep(i,Q){
        int t;
        cin>>t;
        if(t==1){
            ll x,v;
            cin>>x>>v;
            x--;
            seg.apply(x,N,v-A[x]);
            A[x]=v;
        }else{
            ll x;
            cin>>x;
            cout<<(mod+seg.prod(0,x).E)%mod<<"\n";
        }
    }
}


Submission Info

Submission Time
Task F - Cumulative Cumulative Cumulative Sum
User potato167
Language C++ (GCC 9.2.1)
Score 500
Code Size 1616 Byte
Status AC
Exec Time 620 ms
Memory 22192 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 22
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
random_01.txt AC 529 ms 22172 KiB
random_02.txt AC 390 ms 12824 KiB
random_03.txt AC 481 ms 22124 KiB
random_04.txt AC 357 ms 12824 KiB
random_05.txt AC 557 ms 22104 KiB
random_06.txt AC 301 ms 7932 KiB
random_07.txt AC 462 ms 22124 KiB
random_08.txt AC 368 ms 20712 KiB
random_09.txt AC 591 ms 22188 KiB
random_10.txt AC 554 ms 21120 KiB
random_11.txt AC 464 ms 22092 KiB
random_12.txt AC 465 ms 21116 KiB
random_13.txt AC 46 ms 3604 KiB
random_14.txt AC 6 ms 3584 KiB
random_15.txt AC 357 ms 13420 KiB
random_16.txt AC 149 ms 13432 KiB
random_17.txt AC 505 ms 13352 KiB
random_18.txt AC 227 ms 13376 KiB
random_19.txt AC 620 ms 22160 KiB
random_20.txt AC 480 ms 22192 KiB
sample_01.txt AC 4 ms 3552 KiB
sample_02.txt AC 2 ms 3592 KiB