結果

問題 No.2395 区間二次変換一点取得
ユーザー rlangevinrlangevin
提出日時 2023-07-28 21:45:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 541 ms / 2,000 ms
コード長 1,335 bytes
コンパイル時間 444 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 94,208 KB
最終ジャッジ日時 2024-04-16 05:38:25
合計ジャッジ時間 6,686 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,224 KB
testcase_01 AC 44 ms
52,608 KB
testcase_02 AC 40 ms
52,224 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 43 ms
51,968 KB
testcase_05 AC 42 ms
52,352 KB
testcase_06 AC 41 ms
52,480 KB
testcase_07 AC 42 ms
52,224 KB
testcase_08 AC 43 ms
52,864 KB
testcase_09 AC 44 ms
52,992 KB
testcase_10 AC 46 ms
53,248 KB
testcase_11 AC 94 ms
74,368 KB
testcase_12 AC 164 ms
78,208 KB
testcase_13 AC 535 ms
93,568 KB
testcase_14 AC 538 ms
93,824 KB
testcase_15 AC 533 ms
93,568 KB
testcase_16 AC 536 ms
93,696 KB
testcase_17 AC 541 ms
93,440 KB
testcase_18 AC 462 ms
94,208 KB
testcase_19 AC 453 ms
93,696 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, l, r):
        assert 0 <= l <= r <= self._n
        return self._sum(r) - self._sum(l)

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

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

    def get(self, k):
        k += 1
        x, r = 0, 1
        while r < self._n:
            r <<= 1
        len = r
        while len:
            if x + len - 1 < self._n:
                if self.data[x + len - 1] < k:
                    k -= self.data[x + len - 1]
                    x += len
            len >>= 1
        return x


N, B, Q = map(int, input().split())
T = Fenwick_Tree(N + 1)
ans = [(1, 1, 1)]
for i in range(Q):
    x, y, z = ans[-1]
    nx = x + 1
    ny = 3 * y + 2 * nx * z
    nz = 3 * z
    ans.append((nx%B, ny%B, nz%B))
    
for _ in range(Q):
    L, M, R = map(int, input().split())
    L -= 1
    T.add(L, 1)
    T.add(R, -1)
    print(*ans[T.sum(0, M)])
0