結果
問題 | No.1222 -101 |
ユーザー | tamato |
提出日時 | 2020-09-04 23:26:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,667 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 130,840 KB |
最終ジャッジ日時 | 2024-11-26 21:04:26 |
合計ジャッジ時間 | 7,819 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,612 KB |
testcase_01 | AC | 38 ms
54,940 KB |
testcase_02 | AC | 39 ms
53,600 KB |
testcase_03 | AC | 39 ms
53,948 KB |
testcase_04 | AC | 38 ms
53,692 KB |
testcase_05 | AC | 38 ms
53,124 KB |
testcase_06 | AC | 37 ms
53,576 KB |
testcase_07 | AC | 39 ms
53,744 KB |
testcase_08 | WA | - |
testcase_09 | AC | 39 ms
53,420 KB |
testcase_10 | WA | - |
testcase_11 | AC | 97 ms
102,604 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 38 ms
53,364 KB |
testcase_23 | AC | 39 ms
54,256 KB |
testcase_24 | AC | 38 ms
53,472 KB |
testcase_25 | AC | 38 ms
53,616 KB |
testcase_26 | WA | - |
testcase_27 | AC | 39 ms
53,392 KB |
testcase_28 | AC | 39 ms
54,576 KB |
testcase_29 | WA | - |
testcase_30 | AC | 39 ms
53,668 KB |
testcase_31 | AC | 39 ms
52,876 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 211 ms
127,084 KB |
testcase_35 | AC | 209 ms
126,816 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.buffer.readline N, M = map(int, input().split()) LR0 = [] LR1 = [] imos0 = [0] * (N + 2) imos1 = [0] * (N + 2) for _ in range(M): l, r, p = map(int, input().split()) if p == 0: LR0.append((l, r)) imos0[l] += 1 imos0[r+1] -= 1 else: LR1.append((l, r)) imos1[l] += 1 imos1[r+1] -= 1 seg0 = [0] * (N+1) seg1 = [0] * (N+1) F = 0 N1 = 0 dp = [0] * (N+1) dp[0] = 1 LR0.sort(key=lambda x: x[1], reverse=True) RmostL = -1 S = [0] * (N+1) cnt = [0] * (N+1) for i in range(N): seg0[i+1] = seg0[i] + imos0[i+1] seg1[i+1] = seg1[i] + imos1[i+1] if seg0[i+1] == seg1[i+1] == 0: F += 1 dp[i+1] = dp[i] cnt[i+1] = cnt[i] S[i+1] = S[i] elif seg1[i+1] == 0: if LR0: if LR0[-1][1] == i+1: l, r = LR0.pop() RmostL = max(RmostL, l) dp[i+1] = (dp[i] + S[i] - (S[RmostL] * pow(2, cnt[i] - cnt[RmostL]))%mod)%mod S[i+1] = (S[i]*2 + dp[i+1])%mod cnt[i+1] = cnt[i]+1 else: N1 += 1 dp[i+1] = dp[i] cnt[i+1] = cnt[i] S[i+1] = S[i] # min def STfunc(a, b): if a < b: return a else: return b # クエリは0-indexedで[l, r) class SparseTable(): def __init__(self, A): # A: 処理したい数列 self.N = len(A) self.K = self.N.bit_length() - 1 self.table = [0] * (self.N * (self.K + 1)) for i, a in enumerate(A): self.table[i] = a for k in range(1, self.K + 1): for i in range(self.N): j = i + (1 << (k - 1)) if j <= self.N - 1: self.table[i + k * self.N] = STfunc(self.table[i + (k - 1) * self.N], self.table[j + (k - 1) * self.N]) def query(self, l, r): # [l, r)の最小値を求める k = (r - l).bit_length() - 1 return STfunc(self.table[l + k * self.N], self.table[r - (1 << k) + k * self.N]) if seg1: ST = SparseTable(seg1) for l, r in LR0: if ST.query(l, r+1) > 0: print(0) exit() print(((dp[-1] * pow(3, F, mod))%mod * pow(2, N1 - len(LR1), mod))%mod) if __name__ == '__main__': main()