結果

問題 No.801 エレベーター
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-06-24 13:17:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,570 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 204,316 KB
最終ジャッジ日時 2023-09-14 08:40:40
合計ジャッジ時間 6,880 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
77,668 KB
testcase_01 AC 102 ms
72,992 KB
testcase_02 AC 102 ms
72,864 KB
testcase_03 AC 218 ms
81,608 KB
testcase_04 AC 220 ms
81,780 KB
testcase_05 AC 220 ms
81,836 KB
testcase_06 AC 224 ms
81,756 KB
testcase_07 AC 223 ms
81,752 KB
testcase_08 AC 217 ms
81,880 KB
testcase_09 AC 215 ms
81,736 KB
testcase_10 AC 220 ms
81,984 KB
testcase_11 AC 209 ms
81,944 KB
testcase_12 AC 219 ms
81,760 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from functools import *
from itertools import *
from heapq import *
import sys,math
input = sys.stdin.readline
class RSQandRAQ():
    """区間加算、区間取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    query: 区間[l, r)の和を求める
    l, rは0-indexed
    """

    def __init__(self, n):
        self.n = n
        self.bit0 = [0] * (n + 1)
        self.bit1 = [0] * (n + 1)

    def _add(self, bit, i, val):
        i = i + 1
        while i <= self.n:
            bit[i] += val
            i += i & -i

    def _get(self, bit, i):
        s = 0
        while i > 0:
            s += bit[i]
            i -= i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(self.bit0, l, -val * l)
        self._add(self.bit0, r,  val * r)
        self._add(self.bit1, l,  val)
        self._add(self.bit1, r, -val)

    def query(self, l, r):
        """区間[l, r)の和を求める"""
        return self._get(self.bit0, r) + r * self._get(self.bit1, r) \
            - self._get(self.bit0, l) - l * self._get(self.bit1, l)
N,M,K = map(int,input().split())
mod = 10**9 + 7


LR = [tuple(map(int,input().split())) for _ in range(M)]

dp = [[0]*(N+1) for _ in range(K+1)]
dp[0][1] = 1
for i in range(K):
    
    I = RSQandRAQ(N+1)
    S = list(accumulate([0]+dp[i]))
    for l,r in LR:
        
        I.add(l,r+1,S[r+1]-S[l])
    
    for j in range(1,N+1):
        
        dp[i+1][j] = I.query(j,j+1)%mod

print(dp[-1][N])


0