結果

問題 No.1222 -101
ユーザー mkawa2mkawa2
提出日時 2023-06-14 18:45:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,574 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 87,172 KB
最終ジャッジ日時 2023-09-05 05:43:04
合計ジャッジ時間 9,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
79,140 KB
testcase_01 AC 83 ms
79,108 KB
testcase_02 AC 83 ms
79,180 KB
testcase_03 AC 82 ms
79,236 KB
testcase_04 AC 81 ms
79,144 KB
testcase_05 AC 82 ms
79,060 KB
testcase_06 AC 82 ms
79,012 KB
testcase_07 AC 81 ms
79,008 KB
testcase_08 AC 82 ms
78,944 KB
testcase_09 AC 82 ms
79,144 KB
testcase_10 AC 100 ms
85,744 KB
testcase_11 AC 97 ms
85,640 KB
testcase_12 AC 207 ms
87,012 KB
testcase_13 AC 209 ms
87,172 KB
testcase_14 AC 207 ms
87,000 KB
testcase_15 AC 163 ms
87,000 KB
testcase_16 AC 186 ms
87,156 KB
testcase_17 AC 201 ms
87,076 KB
testcase_18 AC 162 ms
86,976 KB
testcase_19 AC 174 ms
86,956 KB
testcase_20 AC 191 ms
87,092 KB
testcase_21 AC 190 ms
87,128 KB
testcase_22 AC 80 ms
79,124 KB
testcase_23 AC 81 ms
79,108 KB
testcase_24 AC 82 ms
79,332 KB
testcase_25 AC 81 ms
79,004 KB
testcase_26 AC 81 ms
79,116 KB
testcase_27 AC 81 ms
79,096 KB
testcase_28 AC 82 ms
78,972 KB
testcase_29 AC 82 ms
78,988 KB
testcase_30 AC 84 ms
79,264 KB
testcase_31 WA -
testcase_32 AC 197 ms
87,020 KB
testcase_33 AC 200 ms
86,932 KB
testcase_34 AC 199 ms
86,720 KB
testcase_35 AC 200 ms
86,700 KB
testcase_36 AC 205 ms
86,788 KB
testcase_37 AC 207 ms
87,160 KB
testcase_38 AC 202 ms
86,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
md = 10**9+7
# md = 998244353

mx = 200005
pw = [1]*mx
ipw = [1]*mx
for i in range(mx-1): pw[i+1] = pw[i]*2%md
ipw[-1] = pow(pw[-1], md-2, md)
for i in range(mx-1)[::-1]: ipw[i] = ipw[i+1]*2%md

n, m = LI()
rtol = [-1]*(n+1)
ng = [0]*(n+2)
c = 0
mxl = -1
for _ in range(m):
    l, r, p = LI()
    if p:
        c += 1
        ng[l] += 1
        ng[r+1] -= 1
    else:
        rtol[r] = l
        mxl = max(mxl, l)
for i in range(n+1): ng[i+1] += ng[i]
# pDB(ng,c)

# dpi=sum(dpj*2^(i-j-1))
# dpi=2^(i-1)*sum(dpj*2^(-j))
dp = [1]*(n+1)
cs = [0]*(n+2)
cs[1] = 1

l = 0
ans = 0
if mxl == -1: ans = pw[n]
for i in range(1, n+1):
    cs[i+1] = cs[i]
    if ng[i]: continue
    v = pw[i-1]*(cs[i]-cs[l])%md
    if i >= mxl:
        ans += v*pw[n-i]%md
        ans %= md
    cs[i+1] += v*ipw[i]%md
    cs[i+1] %= md
    l = max(l, rtol[i])

ans *= ipw[c]
print(ans%md)
0