結果

問題 No.2395 区間二次変換一点取得
ユーザー titiatitia
提出日時 2023-07-30 02:42:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,267 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 36,480 KB
最終ジャッジ日時 2024-04-17 04:53:21
合計ジャッジ時間 11,719 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,624 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 30 ms
10,624 KB
testcase_09 AC 31 ms
10,624 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 38 ms
11,136 KB
testcase_12 AC 132 ms
13,440 KB
testcase_13 AC 1,243 ms
36,480 KB
testcase_14 AC 1,256 ms
36,480 KB
testcase_15 AC 1,255 ms
36,352 KB
testcase_16 AC 1,267 ms
36,480 KB
testcase_17 AC 1,249 ms
36,352 KB
testcase_18 AC 1,229 ms
36,352 KB
testcase_19 AC 1,231 ms
36,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,B,Q=map(int,input().split())

seg_el=1<<((N+1).bit_length()) # Segment treeの台の要素数
SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化

def getvalue(n,seg_el): # 一点の値を取得
    i=n+seg_el
    ANS=SEG[i]
    i>>=1# 子ノードへ
    
    while i!=0:
        ANS+=SEG[i]
        i>>=1

    return ANS

def updates(l,r):
    L=l+seg_el
    R=r+seg_el

    while L<R:
        if L & 1:
            SEG[L]+=1
            L+=1

        if R & 1:
            R-=1
            SEG[R]+=1
        L>>=1
        R>>=1

ANS=[0]*Q

for tests in range(Q):
    L,M,R=map(int,input().split())
    updates(L,R+1)
    ANS[tests]=getvalue(M,seg_el)

LANS=[[1,1,1] for i in range(Q+1)]

for i in range(Q):
    a,b,c=LANS[i]
    na=(a+1)%B
    nb=(3*b+2*na*c)%B
    nc=3*c%B
    LANS[i+1]=[na,nb,nc]

for i in range(Q):
    print(*LANS[ANS[i]])
    
    
0