結果

問題 No.2395 区間二次変換一点取得
ユーザー かつっぱ競プロかつっぱ競プロ
提出日時 2023-07-28 21:39:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,757 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,824 KB
最終ジャッジ日時 2024-04-16 05:30:22
合計ジャッジ時間 16,341 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
18,176 KB
testcase_01 AC 129 ms
18,176 KB
testcase_02 AC 125 ms
18,304 KB
testcase_03 AC 158 ms
25,984 KB
testcase_04 AC 165 ms
25,856 KB
testcase_05 AC 166 ms
28,544 KB
testcase_06 AC 169 ms
28,672 KB
testcase_07 AC 166 ms
28,672 KB
testcase_08 AC 165 ms
28,672 KB
testcase_09 AC 171 ms
28,544 KB
testcase_10 AC 167 ms
28,800 KB
testcase_11 AC 184 ms
28,672 KB
testcase_12 AC 301 ms
28,800 KB
testcase_13 AC 1,719 ms
29,696 KB
testcase_14 AC 1,745 ms
29,696 KB
testcase_15 AC 1,748 ms
29,824 KB
testcase_16 AC 1,724 ms
29,696 KB
testcase_17 AC 1,757 ms
29,824 KB
testcase_18 AC 1,586 ms
29,440 KB
testcase_19 AC 1,556 ms
29,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bit = [0] * (N+10)

def add(x, v):
    x += 1
    while x < len(bit):
        bit[x] += v
        x += x & -x

def getSum(x):
    x += 1
    ans = 0
    while x:
        ans += bit[x]
        x -= x & -x
    return ans
        
xyz = [(1,1,1)] * 110000

for i in range(1, 110000):
    x, y, z = xyz[i-1]
    xyz[i] = (x + 1) % B, (3 * y + 2 * (x+1) * z) % B, 3 * z % B


for _ in range(Q):
    l, m, r = map(int, input().split())
    add(l, 1)
    add(r + 1, -1)
    print(*xyz[getSum(m)])


    
0