結果
問題 | No.1222 -101 |
ユーザー | mkawa2 |
提出日時 | 2023-06-14 18:45:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,574 bytes |
コンパイル時間 | 422 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 86,272 KB |
最終ジャッジ日時 | 2024-06-23 02:10:26 |
合計ジャッジ時間 | 6,238 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
61,696 KB |
testcase_01 | AC | 43 ms
61,568 KB |
testcase_02 | AC | 43 ms
61,824 KB |
testcase_03 | AC | 43 ms
61,952 KB |
testcase_04 | AC | 45 ms
61,952 KB |
testcase_05 | AC | 45 ms
61,824 KB |
testcase_06 | AC | 43 ms
62,208 KB |
testcase_07 | AC | 47 ms
62,208 KB |
testcase_08 | AC | 45 ms
62,208 KB |
testcase_09 | AC | 43 ms
61,696 KB |
testcase_10 | AC | 64 ms
72,704 KB |
testcase_11 | AC | 60 ms
70,912 KB |
testcase_12 | AC | 146 ms
86,272 KB |
testcase_13 | AC | 151 ms
86,016 KB |
testcase_14 | AC | 149 ms
85,888 KB |
testcase_15 | AC | 123 ms
86,016 KB |
testcase_16 | AC | 137 ms
85,888 KB |
testcase_17 | AC | 148 ms
85,888 KB |
testcase_18 | AC | 119 ms
85,760 KB |
testcase_19 | AC | 127 ms
85,888 KB |
testcase_20 | AC | 143 ms
86,272 KB |
testcase_21 | AC | 138 ms
85,888 KB |
testcase_22 | AC | 45 ms
62,080 KB |
testcase_23 | AC | 44 ms
61,952 KB |
testcase_24 | AC | 43 ms
62,208 KB |
testcase_25 | AC | 45 ms
61,696 KB |
testcase_26 | AC | 43 ms
61,696 KB |
testcase_27 | AC | 44 ms
61,952 KB |
testcase_28 | AC | 43 ms
62,208 KB |
testcase_29 | AC | 43 ms
61,952 KB |
testcase_30 | AC | 43 ms
61,952 KB |
testcase_31 | WA | - |
testcase_32 | AC | 142 ms
86,144 KB |
testcase_33 | AC | 147 ms
86,016 KB |
testcase_34 | AC | 140 ms
86,144 KB |
testcase_35 | AC | 142 ms
85,888 KB |
testcase_36 | AC | 162 ms
85,632 KB |
testcase_37 | AC | 163 ms
86,144 KB |
testcase_38 | AC | 152 ms
85,632 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] # 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)