結果

問題 No.2395 区間二次変換一点取得
ユーザー ikomaikoma
提出日時 2023-07-28 22:20:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 387 ms / 2,000 ms
コード長 963 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 104,960 KB
最終ジャッジ日時 2024-04-16 06:18:10
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,096 KB
testcase_01 AC 43 ms
52,224 KB
testcase_02 AC 43 ms
52,352 KB
testcase_03 AC 43 ms
52,352 KB
testcase_04 AC 45 ms
52,224 KB
testcase_05 AC 44 ms
52,096 KB
testcase_06 AC 45 ms
52,736 KB
testcase_07 AC 47 ms
52,224 KB
testcase_08 AC 45 ms
52,480 KB
testcase_09 AC 47 ms
52,864 KB
testcase_10 AC 47 ms
52,992 KB
testcase_11 AC 86 ms
72,704 KB
testcase_12 AC 125 ms
78,976 KB
testcase_13 AC 378 ms
104,832 KB
testcase_14 AC 374 ms
104,832 KB
testcase_15 AC 378 ms
104,832 KB
testcase_16 AC 387 ms
104,960 KB
testcase_17 AC 380 ms
104,832 KB
testcase_18 AC 301 ms
104,704 KB
testcase_19 AC 298 ms
104,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,B,Q=map(int,input().split())
LMR=[list(map(int,input().split())) for _ in range(Q)]
class BIT:
    def __init__(self, n:int):
        self.n = n
        self.size = 1<<(n-1).bit_length()
        self.bit = [0] * (self.size + 1)
        # self.data = [0] * (n) # 本来の配列
    def sum(self, i:int): # [0,i]
        i+=1
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
    def sumrange(self, i:int, j:int): # [i,j)
        return self.sum(j-1) - self.sum(i-1)
    def add(self, i:int, x:int):
        if x==0:return
        # self.data[i] += x
        i+=1
        while i <= self.size:
            self.bit[i] += x
            i += i & -i

x,y,z=1,1,1
ans=[(1,1,1)]
for _ in range(Q):
    x = (x+1)%B
    y = (y*3+2*x*z)%B
    z = 3*z%B
    ans.append((x,y,z))
bit = BIT(N+1)
for l,m,r in LMR:
    bit.add(l-1,1)
    bit.add(r,-1)
    print(*ans[bit.sum(m-1)])
0