結果
問題 | No.945 YKC饅頭 |
ユーザー | roaris |
提出日時 | 2019-12-09 00:59:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,282 ms / 2,000 ms |
コード長 | 2,454 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 82,220 KB |
実行使用メモリ | 109,308 KB |
最終ジャッジ日時 | 2025-01-02 23:55:10 |
合計ジャッジ時間 | 33,984 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,480 KB |
testcase_01 | AC | 38 ms
52,480 KB |
testcase_02 | AC | 62 ms
66,968 KB |
testcase_03 | AC | 107 ms
76,284 KB |
testcase_04 | AC | 62 ms
65,312 KB |
testcase_05 | AC | 79 ms
71,808 KB |
testcase_06 | AC | 96 ms
76,288 KB |
testcase_07 | AC | 103 ms
76,080 KB |
testcase_08 | AC | 61 ms
64,896 KB |
testcase_09 | AC | 80 ms
71,936 KB |
testcase_10 | AC | 97 ms
76,032 KB |
testcase_11 | AC | 77 ms
71,296 KB |
testcase_12 | AC | 93 ms
76,032 KB |
testcase_13 | AC | 100 ms
76,160 KB |
testcase_14 | AC | 100 ms
76,288 KB |
testcase_15 | AC | 60 ms
65,024 KB |
testcase_16 | AC | 76 ms
68,992 KB |
testcase_17 | AC | 94 ms
76,544 KB |
testcase_18 | AC | 107 ms
76,288 KB |
testcase_19 | AC | 62 ms
66,432 KB |
testcase_20 | AC | 65 ms
65,792 KB |
testcase_21 | AC | 67 ms
66,048 KB |
testcase_22 | AC | 108 ms
76,416 KB |
testcase_23 | AC | 111 ms
76,672 KB |
testcase_24 | AC | 101 ms
76,416 KB |
testcase_25 | AC | 105 ms
76,416 KB |
testcase_26 | AC | 106 ms
76,484 KB |
testcase_27 | AC | 66 ms
66,304 KB |
testcase_28 | AC | 65 ms
66,304 KB |
testcase_29 | AC | 40 ms
52,736 KB |
testcase_30 | AC | 39 ms
52,608 KB |
testcase_31 | AC | 214 ms
80,128 KB |
testcase_32 | AC | 274 ms
81,988 KB |
testcase_33 | AC | 478 ms
90,240 KB |
testcase_34 | AC | 691 ms
94,080 KB |
testcase_35 | AC | 1,112 ms
106,240 KB |
testcase_36 | AC | 658 ms
96,260 KB |
testcase_37 | AC | 617 ms
94,848 KB |
testcase_38 | AC | 645 ms
94,080 KB |
testcase_39 | AC | 326 ms
83,868 KB |
testcase_40 | AC | 399 ms
87,460 KB |
testcase_41 | AC | 267 ms
82,304 KB |
testcase_42 | AC | 886 ms
100,480 KB |
testcase_43 | AC | 518 ms
94,976 KB |
testcase_44 | AC | 869 ms
100,224 KB |
testcase_45 | AC | 930 ms
104,320 KB |
testcase_46 | AC | 205 ms
81,520 KB |
testcase_47 | AC | 695 ms
93,568 KB |
testcase_48 | AC | 244 ms
80,896 KB |
testcase_49 | AC | 411 ms
86,528 KB |
testcase_50 | AC | 1,197 ms
104,652 KB |
testcase_51 | AC | 1,258 ms
109,204 KB |
testcase_52 | AC | 1,263 ms
109,300 KB |
testcase_53 | AC | 1,240 ms
109,300 KB |
testcase_54 | AC | 1,249 ms
109,308 KB |
testcase_55 | AC | 1,282 ms
109,304 KB |
testcase_56 | AC | 263 ms
84,864 KB |
testcase_57 | AC | 255 ms
84,992 KB |
testcase_58 | AC | 715 ms
101,632 KB |
testcase_59 | AC | 832 ms
104,448 KB |
testcase_60 | AC | 479 ms
92,416 KB |
testcase_61 | AC | 717 ms
101,888 KB |
testcase_62 | AC | 731 ms
101,632 KB |
testcase_63 | AC | 295 ms
85,760 KB |
testcase_64 | AC | 487 ms
92,800 KB |
testcase_65 | AC | 501 ms
91,776 KB |
testcase_66 | AC | 485 ms
91,392 KB |
testcase_67 | AC | 597 ms
96,768 KB |
testcase_68 | AC | 480 ms
92,672 KB |
testcase_69 | AC | 362 ms
87,344 KB |
testcase_70 | AC | 379 ms
88,064 KB |
testcase_71 | AC | 392 ms
88,064 KB |
testcase_72 | AC | 528 ms
94,336 KB |
testcase_73 | AC | 748 ms
103,552 KB |
ソースコード
import sys input = sys.stdin.readline INF = 2**31 - 1 class LazySegmentTree: def __init__(self, n): LV = (n-1).bit_length() self.N0 = 2 ** LV self.data = [INF] * (2*self.N0) self.lazy = [None] * (2*self.N0) def gindex(self, l, r): L = l + self.N0; R = r + self.N0 lm = (L // (L & -L)) >> 1 rm = (R // (R & -R)) >> 1 while L < R: if R <= rm: yield R if L <= lm: yield L L >>= 1; R >>= 1 while L: yield L L >>= 1 def propagates(self, *ids): for i in reversed(ids): v = self.lazy[i-1] if v is None: continue self.lazy[2*i-1] = self.data[2*i-1] = self.lazy[2*i] = self.data[2*i] = v self.lazy[i-1] = None def update(self, l, r, x): #RUQ change a[l:r) to x *ids, = self.gindex(l, r) self.propagates(*ids) L = self.N0 + l; R = self.N0 + r while L < R: if R & 1: R -= 1 self.lazy[R-1] = self.data[R-1] = x if L & 1: self.lazy[L-1] = self.data[L-1] = x L += 1 L >>= 1; R >>= 1 for i in ids: self.data[i-1] = min(self.data[2*i-1], self.data[2*i]) def query(self, l, r): #RMQ min(a[l:r)) self.propagates(*self.gindex(l, r)) L = self.N0 + l; R = self.N0 + r s = INF while L < R: if R & 1: R -= 1 s = min(s, self.data[R-1]) if L & 1: s = min(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s N, M = map(int, input().split()) LRT = [] for _ in range(M): Li, Ri, Ti = input().split() Li = int(Li) Ri = int(Ri) if Ti=='Y': LRT.append((Li, Ri, 1)) elif Ti=='K': LRT.append((Li, Ri, 2)) elif Ti=='C': LRT.append((Li, Ri, 3)) lst = LazySegmentTree(N) for i in range(M-1, -1, -1): Li, Ri, Ti = LRT[i] lst.update(Li-1, Ri, Ti) Y, K, C = 0, 0, 0 for i in range(N): v = lst.query(i, i+1) if v==1: Y += 1 elif v==2: K += 1 elif v==3: C += 1 print(Y, K, C)