結果

問題 No.876 Range Compress Query
コンテスト
ユーザー 回転
提出日時 2026-11-16 11:24:12
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,518 ms / 2,000 ms
+ 598µs
コード長 798 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 87 ms
コンパイル使用メモリ 64,596 KB
実行使用メモリ 132,864 KB
最終ジャッジ日時 2026-11-16 11:24:29
合計ジャッジ時間 16,048 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from atcoder.lazysegtree import LazySegTree
N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))

def op(x,y):
    xv,xl,xr = x
    yv,yl,yr = y
    if(xl != -1 and yl != -1):
        return (xv+yv+(xr != yl), xl, yr)
    elif(xl == -1):
        return y
    else:
        return x

# v,左,右
e = (0,-1,-1)

def mapping(f,x):
    if(x[1] != -1):
        return (x[0], x[1]+f, x[2]+f)
    else:
        return x

def comp(f,g):
    return f+g

id_ = 0

T = LazySegTree(op, e, mapping, comp, id_, [(0, A[i], A[i]) for i in range(N)])
for _ in range(Q):
    query = list(map(int,input().split()))
    if(query[0] == 1):
        _,l,r,x = query
        l -= 1;r -= 1
        T.apply(l,r+1,x)
    else:
        _,l,r = query
        l -= 1;r -= 1
        print(T.prod(l,r+1)[0] + 1)
0