結果

問題 No.1222 -101
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-09-06 22:42:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 420 ms / 2,000 ms
コード長 1,228 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 84,764 KB
最終ジャッジ日時 2023-08-19 14:28:08
合計ジャッジ時間 10,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,340 KB
testcase_01 AC 70 ms
71,412 KB
testcase_02 AC 63 ms
71,136 KB
testcase_03 AC 73 ms
71,352 KB
testcase_04 AC 63 ms
71,320 KB
testcase_05 AC 72 ms
71,188 KB
testcase_06 AC 64 ms
71,320 KB
testcase_07 AC 70 ms
71,232 KB
testcase_08 AC 66 ms
71,264 KB
testcase_09 AC 72 ms
71,320 KB
testcase_10 AC 360 ms
83,184 KB
testcase_11 AC 285 ms
83,136 KB
testcase_12 AC 319 ms
83,972 KB
testcase_13 AC 318 ms
84,000 KB
testcase_14 AC 301 ms
83,960 KB
testcase_15 AC 327 ms
84,352 KB
testcase_16 AC 309 ms
84,312 KB
testcase_17 AC 319 ms
84,096 KB
testcase_18 AC 306 ms
84,212 KB
testcase_19 AC 324 ms
84,764 KB
testcase_20 AC 312 ms
84,488 KB
testcase_21 AC 332 ms
84,056 KB
testcase_22 AC 64 ms
71,408 KB
testcase_23 AC 72 ms
71,480 KB
testcase_24 AC 61 ms
71,172 KB
testcase_25 AC 71 ms
71,512 KB
testcase_26 AC 62 ms
71,236 KB
testcase_27 AC 69 ms
71,296 KB
testcase_28 AC 63 ms
71,044 KB
testcase_29 AC 73 ms
71,436 KB
testcase_30 AC 67 ms
71,528 KB
testcase_31 AC 72 ms
71,480 KB
testcase_32 AC 415 ms
84,224 KB
testcase_33 AC 420 ms
84,648 KB
testcase_34 AC 187 ms
83,428 KB
testcase_35 AC 198 ms
83,380 KB
testcase_36 AC 190 ms
83,548 KB
testcase_37 AC 198 ms
83,592 KB
testcase_38 AC 187 ms
83,776 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

#print(A)
for i in range(1, N+1):
    A[i] += A[i-1]
#print(A)

B = [0] * (N+2)
B[1] = 1

bt = Bit(N+1)
bt.add(1, pow(2, N, mod))

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

0