結果

問題 No.945 YKC饅頭
ユーザー pekempeypekempey
提出日時 2019-12-08 00:15:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 563 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 88,500 KB
最終ジャッジ日時 2023-08-27 07:11:53
合計ジャッジ時間 24,370 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
81,264 KB
testcase_01 AC 114 ms
81,248 KB
testcase_02 AC 134 ms
81,708 KB
testcase_03 AC 143 ms
81,912 KB
testcase_04 AC 125 ms
81,744 KB
testcase_05 AC 143 ms
81,572 KB
testcase_06 AC 139 ms
81,828 KB
testcase_07 AC 144 ms
81,712 KB
testcase_08 AC 129 ms
81,528 KB
testcase_09 AC 135 ms
81,584 KB
testcase_10 AC 159 ms
81,828 KB
testcase_11 AC 140 ms
81,676 KB
testcase_12 AC 150 ms
81,708 KB
testcase_13 AC 156 ms
82,024 KB
testcase_14 AC 152 ms
81,960 KB
testcase_15 AC 126 ms
81,352 KB
testcase_16 AC 136 ms
81,476 KB
testcase_17 AC 139 ms
81,780 KB
testcase_18 AC 152 ms
81,804 KB
testcase_19 AC 137 ms
81,680 KB
testcase_20 AC 128 ms
81,640 KB
testcase_21 AC 127 ms
81,676 KB
testcase_22 AC 163 ms
82,176 KB
testcase_23 AC 158 ms
82,016 KB
testcase_24 AC 167 ms
82,304 KB
testcase_25 AC 162 ms
81,812 KB
testcase_26 AC 160 ms
82,152 KB
testcase_27 AC 132 ms
81,448 KB
testcase_28 AC 133 ms
81,620 KB
testcase_29 AC 116 ms
81,188 KB
testcase_30 AC 112 ms
81,184 KB
testcase_31 AC 249 ms
83,624 KB
testcase_32 AC 255 ms
84,872 KB
testcase_33 AC 338 ms
85,524 KB
testcase_34 AC 358 ms
84,332 KB
testcase_35 AC 482 ms
86,400 KB
testcase_36 AC 358 ms
83,244 KB
testcase_37 AC 334 ms
83,380 KB
testcase_38 AC 332 ms
84,280 KB
testcase_39 AC 271 ms
84,296 KB
testcase_40 AC 324 ms
85,580 KB
testcase_41 AC 288 ms
84,796 KB
testcase_42 AC 400 ms
84,424 KB
testcase_43 AC 325 ms
83,632 KB
testcase_44 AC 399 ms
84,996 KB
testcase_45 AC 430 ms
84,448 KB
testcase_46 AC 248 ms
84,848 KB
testcase_47 AC 371 ms
85,316 KB
testcase_48 AC 228 ms
83,140 KB
testcase_49 AC 303 ms
85,088 KB
testcase_50 AC 473 ms
84,772 KB
testcase_51 AC 534 ms
86,024 KB
testcase_52 AC 498 ms
86,020 KB
testcase_53 AC 539 ms
86,164 KB
testcase_54 AC 503 ms
86,132 KB
testcase_55 AC 510 ms
86,676 KB
testcase_56 AC 247 ms
85,476 KB
testcase_57 AC 170 ms
85,232 KB
testcase_58 AC 487 ms
86,120 KB
testcase_59 AC 530 ms
86,288 KB
testcase_60 AC 373 ms
86,024 KB
testcase_61 AC 563 ms
88,492 KB
testcase_62 AC 508 ms
85,956 KB
testcase_63 AC 188 ms
85,596 KB
testcase_64 AC 397 ms
85,928 KB
testcase_65 AC 371 ms
86,044 KB
testcase_66 AC 362 ms
85,828 KB
testcase_67 AC 504 ms
88,500 KB
testcase_68 AC 386 ms
86,060 KB
testcase_69 AC 309 ms
87,744 KB
testcase_70 AC 292 ms
86,600 KB
testcase_71 AC 299 ms
86,580 KB
testcase_72 AC 433 ms
85,976 KB
testcase_73 AC 513 ms
85,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N, M = map(int, input().split())

def merge(x, y):
  if x is None: return y
  return x

U = 1 << 18
seg = [None] * (U * 2)
for i in range(N + 1):
  seg[i + U] = i

for i in reversed(range(1, U)):
  seg[i] = merge(seg[i * 2], seg[i * 2 + 1])

def erase(k):
  k += U
  seg[k] = None
  while k > 1:
    k >>= 1
    seg[k] = merge(seg[k * 2], seg[k * 2 + 1])

def find(l):
  l += U
  r = 2*U - 1
  resl = None
  resr = None
  while l <= r:
    if l % 2 == 1:
      resl = merge(resl, seg[l])
      l += 1
    if r % 2 == 0:
      resr = merge(seg[r], resr)
      r -= 1
    l >>= 1
    r >>= 1
  return merge(resl, resr)

ans = defaultdict(int)

for _ in range(M):
  l, r, t = input().split()
  l = int(l) - 1
  r = int(r) - 1
  while True:
    l = find(l)
    if l > r: break
    ans[t] += 1
    erase(l)

print(ans['Y'], ans['K'], ans['C'])

    
0