結果

問題 No.2395 区間二次変換一点取得
ユーザー hiro1729hiro1729
提出日時 2023-07-26 11:49:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,969 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-04-12 11:02:49
合計ジャッジ時間 16,182 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 32 ms
10,752 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 32 ms
10,880 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 32 ms
10,624 KB
testcase_08 AC 32 ms
10,752 KB
testcase_09 AC 32 ms
10,880 KB
testcase_10 AC 33 ms
10,752 KB
testcase_11 AC 46 ms
10,752 KB
testcase_12 AC 194 ms
10,880 KB
testcase_13 AC 1,924 ms
11,776 KB
testcase_14 AC 1,921 ms
11,776 KB
testcase_15 AC 1,962 ms
11,904 KB
testcase_16 AC 1,913 ms
11,904 KB
testcase_17 AC 1,969 ms
12,032 KB
testcase_18 AC 1,828 ms
11,520 KB
testcase_19 AC 1,812 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Fenwick_Tree:
    def __init__(self, n):
        self._n = n
        self.data = [0] * n
    
    def add(self, p, x):
        assert 0 <= p < self._n
        p += 1
        while p <= self._n:
            self.data[p - 1] += x
            p += p & -p

    def sum(self, r):
        s = 0
        while r > 0:
            s += self.data[r - 1]
            r -= r & -r
        return s

n, b, q = map(int, input().split())
f = Fenwick_Tree(n + 1)
for i in range(q):
	l, m, r = map(int, input().split())
	f.add(l - 1, 1)
	f.add(r, -1)
	x = f.sum(m)
	print((x + 1) % b, pow(3, x - 1, b) * (x * x + 3 * x + 3) % b, pow(3, x, b))
0