結果

問題 No.945 YKC饅頭
ユーザー mkawa2mkawa2
提出日時 2019-12-12 09:20:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,943 bytes
コンパイル時間 485 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 30,848 KB
最終ジャッジ日時 2023-09-07 00:04:36
合計ジャッジ時間 8,807 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
13,208 KB
testcase_01 AC 19 ms
8,716 KB
testcase_02 AC 22 ms
8,796 KB
testcase_03 AC 34 ms
9,000 KB
testcase_04 AC 20 ms
8,836 KB
testcase_05 AC 23 ms
8,812 KB
testcase_06 AC 29 ms
9,000 KB
testcase_07 AC 26 ms
9,016 KB
testcase_08 AC 20 ms
8,696 KB
testcase_09 AC 24 ms
8,976 KB
testcase_10 AC 27 ms
9,012 KB
testcase_11 AC 24 ms
8,800 KB
testcase_12 AC 25 ms
8,776 KB
testcase_13 AC 32 ms
9,080 KB
testcase_14 AC 31 ms
8,900 KB
testcase_15 AC 21 ms
8,836 KB
testcase_16 AC 22 ms
8,904 KB
testcase_17 AC 28 ms
8,964 KB
testcase_18 AC 29 ms
8,864 KB
testcase_19 AC 20 ms
8,676 KB
testcase_20 AC 21 ms
8,804 KB
testcase_21 AC 21 ms
8,896 KB
testcase_22 AC 35 ms
9,084 KB
testcase_23 AC 34 ms
8,992 KB
testcase_24 AC 34 ms
9,080 KB
testcase_25 AC 34 ms
9,020 KB
testcase_26 AC 35 ms
8,956 KB
testcase_27 AC 19 ms
8,848 KB
testcase_28 AC 20 ms
8,868 KB
testcase_29 AC 19 ms
8,796 KB
testcase_30 AC 19 ms
8,828 KB
testcase_31 AC 262 ms
13,980 KB
testcase_32 AC 125 ms
15,036 KB
testcase_33 AC 1,300 ms
30,848 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 #

from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

class SegmentTree:
    def __init__(self, aa):
        width = 1 << ((len(aa) - 1).bit_length())
        tree = [-1] * (width * 2 - 1)
        lazy = [-1] * (width * 2 - 1)
        tree[width - 1:] = aa
        self.width = width
        self.tree = tree
        self.lazy = lazy

    def _prop(self, u):
        if self.lazy[u] == -1: return
        value = self.tree[u] = self.lazy[u]
        self.lazy[u] = -1
        if u < self.width - 1:
            self.lazy[u * 2 + 1] = self.lazy[u * 2 + 2] = value

    def update(self, l, r, a, u=0, uL=0, uR=-1):
        if uR == -1: uR = self.width
        self._prop(u)
        if r <= uL or uR <= l:
            return
        elif l <= uL and uR <= r:
            self.lazy[u] = a
            return
        uM = (uL + uR) // 2
        self.update(l, r, a, u * 2 + 1, uL, uM)
        self.update(l, r, a, u * 2 + 2, uM, uR)

    def get_elements(self):
        for u in range(self.width - 1):
            self._prop(u)
        for u in range(self.width - 1, self.width * 2 - 1):
            if self.lazy[u] == -1: continue
            self.tree[u] = self.lazy[u]
        return self.tree[self.width - 1:]

def main():
    n, m = MI()
    lrt = [input().split() for _ in range(m)]
    aa = [-1] * n
    st = SegmentTree(aa)
    for l, r, t in lrt[::-1]:
        l, r = int1(l), int(r)
        if t == "Y":
            mark = 1
        elif t == "K":
            mark = 2
        else:
            mark = 3
        st.update(l, r, mark)
    aa = st.get_elements()
    cnt = defaultdict(int)
    for a in aa:
        cnt[a] += 1
    print(cnt[1], cnt[2], cnt[3])

main()
0