結果
問題 | No.945 YKC饅頭 |
ユーザー | roaris |
提出日時 | 2019-12-08 10:55:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,139 ms / 2,000 ms |
コード長 | 2,419 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 110,908 KB |
最終ジャッジ日時 | 2024-06-09 11:47:31 |
合計ジャッジ時間 | 27,820 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
52,736 KB |
testcase_01 | AC | 39 ms
52,736 KB |
testcase_02 | AC | 53 ms
67,200 KB |
testcase_03 | AC | 79 ms
76,288 KB |
testcase_04 | AC | 48 ms
65,152 KB |
testcase_05 | AC | 63 ms
71,424 KB |
testcase_06 | AC | 75 ms
76,288 KB |
testcase_07 | AC | 76 ms
76,160 KB |
testcase_08 | AC | 49 ms
65,024 KB |
testcase_09 | AC | 63 ms
72,192 KB |
testcase_10 | AC | 75 ms
76,288 KB |
testcase_11 | AC | 61 ms
71,552 KB |
testcase_12 | AC | 75 ms
75,392 KB |
testcase_13 | AC | 85 ms
75,904 KB |
testcase_14 | AC | 79 ms
75,904 KB |
testcase_15 | AC | 55 ms
65,280 KB |
testcase_16 | AC | 56 ms
69,120 KB |
testcase_17 | AC | 77 ms
76,416 KB |
testcase_18 | AC | 83 ms
76,688 KB |
testcase_19 | AC | 51 ms
66,048 KB |
testcase_20 | AC | 53 ms
66,048 KB |
testcase_21 | AC | 52 ms
65,920 KB |
testcase_22 | AC | 78 ms
76,032 KB |
testcase_23 | AC | 85 ms
76,208 KB |
testcase_24 | AC | 80 ms
76,300 KB |
testcase_25 | AC | 83 ms
76,288 KB |
testcase_26 | AC | 86 ms
76,032 KB |
testcase_27 | AC | 50 ms
66,176 KB |
testcase_28 | AC | 51 ms
66,432 KB |
testcase_29 | AC | 33 ms
52,224 KB |
testcase_30 | AC | 33 ms
52,352 KB |
testcase_31 | AC | 173 ms
80,128 KB |
testcase_32 | AC | 228 ms
81,152 KB |
testcase_33 | AC | 405 ms
90,396 KB |
testcase_34 | AC | 573 ms
94,336 KB |
testcase_35 | AC | 937 ms
106,880 KB |
testcase_36 | AC | 542 ms
97,280 KB |
testcase_37 | AC | 515 ms
95,860 KB |
testcase_38 | AC | 574 ms
94,976 KB |
testcase_39 | AC | 286 ms
83,456 KB |
testcase_40 | AC | 352 ms
87,772 KB |
testcase_41 | AC | 241 ms
81,860 KB |
testcase_42 | AC | 748 ms
101,248 KB |
testcase_43 | AC | 440 ms
95,488 KB |
testcase_44 | AC | 721 ms
101,376 KB |
testcase_45 | AC | 842 ms
105,344 KB |
testcase_46 | AC | 173 ms
81,712 KB |
testcase_47 | AC | 592 ms
93,952 KB |
testcase_48 | AC | 206 ms
81,164 KB |
testcase_49 | AC | 366 ms
86,272 KB |
testcase_50 | AC | 862 ms
105,560 KB |
testcase_51 | AC | 1,139 ms
110,744 KB |
testcase_52 | AC | 1,076 ms
110,908 KB |
testcase_53 | AC | 1,055 ms
110,904 KB |
testcase_54 | AC | 1,094 ms
110,772 KB |
testcase_55 | AC | 1,107 ms
110,384 KB |
testcase_56 | AC | 227 ms
84,608 KB |
testcase_57 | AC | 224 ms
84,772 KB |
testcase_58 | AC | 620 ms
102,656 KB |
testcase_59 | AC | 857 ms
105,856 KB |
testcase_60 | AC | 410 ms
92,192 KB |
testcase_61 | AC | 609 ms
102,908 KB |
testcase_62 | AC | 645 ms
102,516 KB |
testcase_63 | AC | 253 ms
85,376 KB |
testcase_64 | AC | 431 ms
93,196 KB |
testcase_65 | AC | 423 ms
92,160 KB |
testcase_66 | AC | 417 ms
91,520 KB |
testcase_67 | AC | 511 ms
97,532 KB |
testcase_68 | AC | 415 ms
92,416 KB |
testcase_69 | AC | 314 ms
87,212 KB |
testcase_70 | AC | 326 ms
88,048 KB |
testcase_71 | AC | 332 ms
88,352 KB |
testcase_72 | AC | 457 ms
95,372 KB |
testcase_73 | AC | 669 ms
104,320 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, Ri = int(Li), int(Ri) if Ti=='Y': LRT.append((Li, Ri, 0)) elif Ti=='K': LRT.append((Li, Ri, 1)) elif Ti=='C': LRT.append((Li, Ri, 2)) LRT = LRT[::-1] lst = LazySegmentTree(N) for Li, Ri, Ti in LRT: 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==0: Y += 1 elif v==1: K += 1 elif v==2: C += 1 print(Y, K, C)