結果
問題 | No.945 YKC饅頭 |
ユーザー | roaris |
提出日時 | 2019-12-09 00:59:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,149 ms / 2,000 ms |
コード長 | 2,454 bytes |
コンパイル時間 | 419 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 109,240 KB |
最終ジャッジ日時 | 2024-06-10 23:09:31 |
合計ジャッジ時間 | 30,979 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,224 KB |
testcase_01 | AC | 36 ms
52,480 KB |
testcase_02 | AC | 61 ms
66,944 KB |
testcase_03 | AC | 96 ms
75,776 KB |
testcase_04 | AC | 64 ms
65,152 KB |
testcase_05 | AC | 82 ms
72,064 KB |
testcase_06 | AC | 92 ms
76,416 KB |
testcase_07 | AC | 88 ms
75,904 KB |
testcase_08 | AC | 55 ms
65,024 KB |
testcase_09 | AC | 72 ms
72,320 KB |
testcase_10 | AC | 87 ms
76,032 KB |
testcase_11 | AC | 71 ms
71,040 KB |
testcase_12 | AC | 84 ms
75,904 KB |
testcase_13 | AC | 95 ms
76,288 KB |
testcase_14 | AC | 94 ms
76,416 KB |
testcase_15 | AC | 56 ms
64,896 KB |
testcase_16 | AC | 67 ms
69,248 KB |
testcase_17 | AC | 87 ms
76,416 KB |
testcase_18 | AC | 95 ms
76,160 KB |
testcase_19 | AC | 60 ms
66,304 KB |
testcase_20 | AC | 59 ms
66,048 KB |
testcase_21 | AC | 60 ms
65,920 KB |
testcase_22 | AC | 93 ms
76,032 KB |
testcase_23 | AC | 98 ms
76,672 KB |
testcase_24 | AC | 92 ms
76,416 KB |
testcase_25 | AC | 95 ms
76,288 KB |
testcase_26 | AC | 94 ms
76,032 KB |
testcase_27 | AC | 59 ms
66,560 KB |
testcase_28 | AC | 60 ms
65,920 KB |
testcase_29 | AC | 37 ms
52,608 KB |
testcase_30 | AC | 36 ms
52,608 KB |
testcase_31 | AC | 187 ms
80,000 KB |
testcase_32 | AC | 245 ms
81,288 KB |
testcase_33 | AC | 429 ms
90,240 KB |
testcase_34 | AC | 607 ms
94,080 KB |
testcase_35 | AC | 1,019 ms
106,496 KB |
testcase_36 | AC | 581 ms
96,128 KB |
testcase_37 | AC | 550 ms
94,592 KB |
testcase_38 | AC | 593 ms
94,208 KB |
testcase_39 | AC | 308 ms
83,508 KB |
testcase_40 | AC | 376 ms
87,132 KB |
testcase_41 | AC | 247 ms
82,176 KB |
testcase_42 | AC | 800 ms
100,224 KB |
testcase_43 | AC | 453 ms
94,592 KB |
testcase_44 | AC | 806 ms
99,968 KB |
testcase_45 | AC | 852 ms
104,216 KB |
testcase_46 | AC | 191 ms
81,320 KB |
testcase_47 | AC | 634 ms
93,568 KB |
testcase_48 | AC | 218 ms
81,024 KB |
testcase_49 | AC | 378 ms
86,272 KB |
testcase_50 | AC | 915 ms
104,536 KB |
testcase_51 | AC | 1,149 ms
109,004 KB |
testcase_52 | AC | 1,145 ms
109,240 KB |
testcase_53 | AC | 1,114 ms
109,224 KB |
testcase_54 | AC | 1,144 ms
109,092 KB |
testcase_55 | AC | 1,144 ms
108,844 KB |
testcase_56 | AC | 239 ms
84,608 KB |
testcase_57 | AC | 243 ms
85,120 KB |
testcase_58 | AC | 654 ms
101,376 KB |
testcase_59 | AC | 759 ms
104,320 KB |
testcase_60 | AC | 449 ms
92,416 KB |
testcase_61 | AC | 656 ms
101,632 KB |
testcase_62 | AC | 669 ms
100,992 KB |
testcase_63 | AC | 269 ms
85,248 KB |
testcase_64 | AC | 447 ms
93,056 KB |
testcase_65 | AC | 447 ms
91,392 KB |
testcase_66 | AC | 444 ms
91,520 KB |
testcase_67 | AC | 556 ms
96,384 KB |
testcase_68 | AC | 455 ms
92,160 KB |
testcase_69 | AC | 332 ms
87,108 KB |
testcase_70 | AC | 347 ms
87,744 KB |
testcase_71 | AC | 352 ms
87,800 KB |
testcase_72 | AC | 480 ms
94,720 KB |
testcase_73 | AC | 677 ms
103,808 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)