結果

問題 No.1222 -101
ユーザー anagohirameanagohirame
提出日時 2020-07-18 02:15:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 872 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 43,776 KB
最終ジャッジ日時 2024-04-23 06:51:55
合計ジャッジ時間 16,402 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 31 ms
10,752 KB
testcase_08 AC 31 ms
10,752 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 469 ms
37,504 KB
testcase_11 AC 453 ms
37,632 KB
testcase_12 AC 820 ms
40,576 KB
testcase_13 AC 815 ms
40,576 KB
testcase_14 AC 829 ms
40,576 KB
testcase_15 AC 637 ms
39,040 KB
testcase_16 AC 751 ms
39,936 KB
testcase_17 AC 798 ms
40,320 KB
testcase_18 AC 631 ms
38,912 KB
testcase_19 AC 682 ms
39,168 KB
testcase_20 AC 745 ms
39,936 KB
testcase_21 AC 731 ms
39,808 KB
testcase_22 AC 32 ms
10,880 KB
testcase_23 AC 31 ms
10,880 KB
testcase_24 AC 33 ms
10,880 KB
testcase_25 AC 31 ms
10,752 KB
testcase_26 AC 32 ms
10,880 KB
testcase_27 AC 30 ms
10,752 KB
testcase_28 AC 33 ms
10,880 KB
testcase_29 AC 31 ms
10,880 KB
testcase_30 AC 31 ms
10,880 KB
testcase_31 AC 30 ms
10,752 KB
testcase_32 AC 866 ms
43,776 KB
testcase_33 AC 872 ms
43,776 KB
testcase_34 AC 780 ms
37,632 KB
testcase_35 AC 772 ms
37,632 KB
testcase_36 AC 768 ms
37,504 KB
testcase_37 AC 768 ms
37,632 KB
testcase_38 AC 750 ms
37,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 10**9+7
n, m = map(int, input().split())
two_pow = [1 for _ in range(n+2)]
for i in range(1, n+2):
	two_pow[i] = (two_pow[i-1] * 2) % MOD

zero_seg = [0 for _ in range(n+1)]
nonzero_num = 0
nonzero_imos = [0 for _ in range(n+2)]
for _ in range(m):
	l, r, p = map(int, input().split())
	if p == 0:
		zero_seg[r] = l
	else:
		nonzero_num += 1
		nonzero_imos[l] += 1
		nonzero_imos[r+1] -= 1

for i in range(2, n+2):
	nonzero_imos[i] += nonzero_imos[i-1]

dp = [0 for _ in range(n+1)]
cum = [0 for _ in range(n+2)]
dp[0] = 1
cum[0] = 1
max_left = 0

for i in range(1, n+1):
	if nonzero_imos[i] == 0:
		dp[i] = (cum[i-1] - two_pow[i-max_left] * cum[max_left-1]) % MOD
	cum[i] = (2*cum[i-1] + dp[i]) % MOD
	max_left = max(max_left, zero_seg[i])

pre_ans = (cum[n] - two_pow[n-max_left+1] * cum[max_left-1]) % MOD
ans = (pre_ans * pow(500000004, nonzero_num, MOD)) % MOD
print(ans)
0