結果

問題 No.1222 -101
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-09-06 22:46:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 866 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 83,120 KB
最終ジャッジ日時 2023-08-19 14:28:31
合計ジャッジ時間 9,754 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,244 KB
testcase_01 AC 72 ms
70,976 KB
testcase_02 AC 67 ms
71,128 KB
testcase_03 AC 67 ms
71,240 KB
testcase_04 AC 71 ms
71,236 KB
testcase_05 AC 67 ms
71,124 KB
testcase_06 AC 76 ms
71,084 KB
testcase_07 AC 74 ms
71,084 KB
testcase_08 AC 74 ms
71,100 KB
testcase_09 AC 74 ms
71,040 KB
testcase_10 AC 359 ms
81,984 KB
testcase_11 AC 316 ms
81,272 KB
testcase_12 AC 326 ms
82,372 KB
testcase_13 AC 368 ms
82,612 KB
testcase_14 AC 325 ms
82,268 KB
testcase_15 AC 314 ms
82,584 KB
testcase_16 AC 317 ms
82,264 KB
testcase_17 AC 349 ms
82,648 KB
testcase_18 AC 309 ms
82,340 KB
testcase_19 AC 319 ms
82,972 KB
testcase_20 AC 304 ms
83,120 KB
testcase_21 AC 301 ms
82,328 KB
testcase_22 AC 72 ms
71,220 KB
testcase_23 AC 65 ms
71,428 KB
testcase_24 AC 72 ms
70,992 KB
testcase_25 AC 62 ms
71,412 KB
testcase_26 AC 70 ms
71,276 KB
testcase_27 AC 62 ms
71,440 KB
testcase_28 AC 73 ms
71,220 KB
testcase_29 AC 64 ms
70,984 KB
testcase_30 AC 73 ms
71,288 KB
testcase_31 AC 75 ms
71,288 KB
testcase_32 AC 409 ms
82,284 KB
testcase_33 AC 392 ms
82,092 KB
testcase_34 AC 189 ms
81,632 KB
testcase_35 AC 184 ms
81,632 KB
testcase_36 AC 190 ms
82,084 KB
testcase_37 AC 180 ms
82,036 KB
testcase_38 AC 194 ms
81,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, M = map(int, input().split())
mod = 10**9+7
A = [0] * (N+1)
r2l = [0] * (N+1)
c = 0
for _ in range(M):
    l, r, p = map(int, input().split())
    if p:
        A[l-1] += 1
        A[r] -= 1
        c += 1
    else:
        r2l[r] = l

bt = Bit(N+1)
bt.add(1, pow(2, N, mod))
mxl = 0
m2=500000004
for i in range(1, N+1):
    A[i] += A[i-1]
    if A[i-1] == 0:
        bt.add(i+1, pow(2, N-i, mod)*pow(m2, N-i+1, mod)*(bt.sum(i) - bt.sum(mxl))%mod)
    mxl = max(mxl, r2l[i])
print((bt.sum(N+1)-bt.sum(mxl))*pow(m2, c, mod)%mod)

0