結果

問題 No.945 YKC饅頭
ユーザー prd_xxxprd_xxx
提出日時 2019-12-08 00:59:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 2,152 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,060 KB
実行使用メモリ 59,964 KB
最終ジャッジ日時 2023-08-27 14:16:52
合計ジャッジ時間 9,775 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,528 KB
testcase_01 AC 18 ms
8,076 KB
testcase_02 AC 19 ms
8,124 KB
testcase_03 AC 32 ms
8,760 KB
testcase_04 AC 18 ms
8,256 KB
testcase_05 AC 24 ms
8,640 KB
testcase_06 AC 28 ms
8,780 KB
testcase_07 AC 25 ms
8,676 KB
testcase_08 AC 19 ms
8,156 KB
testcase_09 AC 23 ms
8,556 KB
testcase_10 AC 27 ms
8,776 KB
testcase_11 AC 21 ms
8,568 KB
testcase_12 AC 25 ms
8,576 KB
testcase_13 AC 30 ms
8,860 KB
testcase_14 AC 29 ms
8,812 KB
testcase_15 AC 20 ms
8,220 KB
testcase_16 AC 20 ms
8,160 KB
testcase_17 AC 25 ms
8,772 KB
testcase_18 AC 26 ms
8,732 KB
testcase_19 AC 21 ms
8,452 KB
testcase_20 AC 19 ms
8,148 KB
testcase_21 AC 18 ms
8,112 KB
testcase_22 AC 34 ms
8,892 KB
testcase_23 AC 34 ms
8,872 KB
testcase_24 AC 34 ms
8,784 KB
testcase_25 AC 33 ms
8,872 KB
testcase_26 AC 34 ms
8,824 KB
testcase_27 AC 20 ms
8,444 KB
testcase_28 AC 20 ms
8,292 KB
testcase_29 AC 16 ms
8,180 KB
testcase_30 AC 16 ms
8,216 KB
testcase_31 AC 373 ms
13,568 KB
testcase_32 AC 610 ms
13,496 KB
testcase_33 AC 1,743 ms
31,344 KB
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N,M = map(int,input().split())
LRT = [input().split() for i in range(M)]

#参照
#https://smijake3.hatenablog.com/entry/2018/11/03/100133

INF = 2**31-1

LV = N.bit_length()
N0 = 2**LV
data = [INF]*(2*N0)
lazy = [None]*(2*N0)

# 伝搬される区間のインデックス(1-indexed)を全て列挙するgenerator
LV = (N-1).bit_length()
N0 = 2**LV
def gindex(l, r):
    L = l + N0; R = r + 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

# 1-indexedで単調増加のインデックスリストを渡す
def propagates(*ids):
    for i in reversed(ids):
        v = lazy[i-1]
        if v is None:
            continue
        lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = v
        lazy[i-1] = None

def update(l, r, x):
    *ids, = gindex(l, r)
    # 1. トップダウンにlazyの値を伝搬
    propagates(*ids)

    # 2. 区間[l, r)のdata, lazyの値を更新
    L = N0 + l; R = N0 + r
    while L < R:
        if R & 1:
            R -= 1
            lazy[R-1] = data[R-1] = x
        if L & 1:
            lazy[L-1] = data[L-1] = x
            L += 1
        L >>= 1; R >>= 1

    # 3. 伝搬させた区間について、ボトムアップにdataの値を伝搬する
    for i in ids:
        data[i-1] = min(data[2*i-1], data[2*i])

def query(l, r):
    # 1. トップダウンにlazyの値を伝搬
    propagates(*gindex(l, r))
    L = N0 + l; R = N0 + r

    # 2. 区間[l, r)の最小値を求める
    s = INF
    while L < R:
        if R & 1:
            R -= 1
            s = min(s, data[R-1])
        if L & 1:
            s = min(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s



for i,(l,r,t) in reversed(list(enumerate(LRT))):
    l,r = int(l),int(r)
    update(l,r+1,i)

y = k = c = 0
for i in range(1,N+1):
    j = query(i,i+1)
    if j >= M: continue
    t = LRT[j][2]
    if t=='Y':
        y += 1
    elif t=='K':
        k += 1
    else:
        c += 1
print(y,k,c)
0