結果
問題 | No.1222 -101 |
ユーザー | tamato |
提出日時 | 2020-09-05 00:02:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,732 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 130,420 KB |
最終ジャッジ日時 | 2024-05-05 03:48:51 |
合計ジャッジ時間 | 7,325 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,480 KB |
testcase_01 | AC | 40 ms
52,480 KB |
testcase_02 | AC | 41 ms
52,992 KB |
testcase_03 | AC | 37 ms
52,608 KB |
testcase_04 | AC | 37 ms
52,480 KB |
testcase_05 | AC | 36 ms
52,992 KB |
testcase_06 | AC | 38 ms
52,224 KB |
testcase_07 | AC | 41 ms
52,608 KB |
testcase_08 | WA | - |
testcase_09 | AC | 40 ms
52,480 KB |
testcase_10 | WA | - |
testcase_11 | AC | 100 ms
101,504 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 | 35 ms
52,736 KB |
testcase_23 | AC | 36 ms
52,608 KB |
testcase_24 | AC | 35 ms
52,864 KB |
testcase_25 | AC | 33 ms
52,608 KB |
testcase_26 | WA | - |
testcase_27 | AC | 34 ms
53,120 KB |
testcase_28 | AC | 35 ms
52,992 KB |
testcase_29 | WA | - |
testcase_30 | AC | 36 ms
52,480 KB |
testcase_31 | AC | 35 ms
52,608 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 204 ms
126,876 KB |
testcase_35 | AC | 195 ms
126,872 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+2) cnt = [0] * (N+1) S[0] = 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] = (S[i] - (S[RmostL] * pow(2, cnt[i]+1 - cnt[RmostL]))%mod)%mod dp[i + 1] = S[i] 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) #print(dp) #print(S) if __name__ == '__main__': main()