結果
問題 | No.1222 -101 |
ユーザー | mkawa2 |
提出日時 | 2023-06-14 22:14:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 1,565 bytes |
コンパイル時間 | 338 ms |
コンパイル使用メモリ | 82,064 KB |
実行使用メモリ | 84,480 KB |
最終ジャッジ日時 | 2024-06-23 03:50:19 |
合計ジャッジ時間 | 6,118 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
62,148 KB |
testcase_01 | AC | 45 ms
61,824 KB |
testcase_02 | AC | 44 ms
61,696 KB |
testcase_03 | AC | 45 ms
61,568 KB |
testcase_04 | AC | 44 ms
61,952 KB |
testcase_05 | AC | 45 ms
61,824 KB |
testcase_06 | AC | 46 ms
61,824 KB |
testcase_07 | AC | 45 ms
62,080 KB |
testcase_08 | AC | 45 ms
62,080 KB |
testcase_09 | AC | 47 ms
61,696 KB |
testcase_10 | AC | 67 ms
71,040 KB |
testcase_11 | AC | 64 ms
69,248 KB |
testcase_12 | AC | 153 ms
83,992 KB |
testcase_13 | AC | 175 ms
84,224 KB |
testcase_14 | AC | 155 ms
84,316 KB |
testcase_15 | AC | 125 ms
84,224 KB |
testcase_16 | AC | 143 ms
84,480 KB |
testcase_17 | AC | 156 ms
83,972 KB |
testcase_18 | AC | 122 ms
84,224 KB |
testcase_19 | AC | 130 ms
84,148 KB |
testcase_20 | AC | 144 ms
84,352 KB |
testcase_21 | AC | 141 ms
84,188 KB |
testcase_22 | AC | 47 ms
62,080 KB |
testcase_23 | AC | 45 ms
62,080 KB |
testcase_24 | AC | 44 ms
62,336 KB |
testcase_25 | AC | 45 ms
61,824 KB |
testcase_26 | AC | 46 ms
62,080 KB |
testcase_27 | AC | 45 ms
62,080 KB |
testcase_28 | AC | 46 ms
61,824 KB |
testcase_29 | AC | 45 ms
62,208 KB |
testcase_30 | AC | 43 ms
61,568 KB |
testcase_31 | AC | 44 ms
61,824 KB |
testcase_32 | AC | 153 ms
83,980 KB |
testcase_33 | AC | 154 ms
84,220 KB |
testcase_34 | AC | 144 ms
83,916 KB |
testcase_35 | AC | 152 ms
83,840 KB |
testcase_36 | AC | 149 ms
84,096 KB |
testcase_37 | AC | 152 ms
84,480 KB |
testcase_38 | AC | 153 ms
84,024 KB |
ソースコード
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] # dpi=sum(dpj*2^(i-j-1)) # dpi=2^(i-1)*sum(dpj*2^(-j)) 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]==0: 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)