結果

問題 No.945 YKC饅頭
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-03-10 19:35:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 909 ms / 2,000 ms
コード長 1,899 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 96,792 KB
最終ジャッジ日時 2023-10-12 22:14:20
合計ジャッジ時間 33,512 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,636 KB
testcase_01 AC 91 ms
71,720 KB
testcase_02 AC 120 ms
77,248 KB
testcase_03 AC 142 ms
77,744 KB
testcase_04 AC 102 ms
76,704 KB
testcase_05 AC 150 ms
77,908 KB
testcase_06 AC 148 ms
77,816 KB
testcase_07 AC 141 ms
77,528 KB
testcase_08 AC 112 ms
77,036 KB
testcase_09 AC 117 ms
77,136 KB
testcase_10 AC 154 ms
77,620 KB
testcase_11 AC 126 ms
77,204 KB
testcase_12 AC 155 ms
78,064 KB
testcase_13 AC 158 ms
77,672 KB
testcase_14 AC 159 ms
77,784 KB
testcase_15 AC 105 ms
75,672 KB
testcase_16 AC 119 ms
77,108 KB
testcase_17 AC 123 ms
76,820 KB
testcase_18 AC 155 ms
77,968 KB
testcase_19 AC 144 ms
77,500 KB
testcase_20 AC 113 ms
77,004 KB
testcase_21 AC 108 ms
76,800 KB
testcase_22 AC 176 ms
77,844 KB
testcase_23 AC 169 ms
77,960 KB
testcase_24 AC 169 ms
77,816 KB
testcase_25 AC 172 ms
77,936 KB
testcase_26 AC 168 ms
77,596 KB
testcase_27 AC 129 ms
77,272 KB
testcase_28 AC 125 ms
77,372 KB
testcase_29 AC 94 ms
71,728 KB
testcase_30 AC 92 ms
71,276 KB
testcase_31 AC 311 ms
83,192 KB
testcase_32 AC 387 ms
87,508 KB
testcase_33 AC 531 ms
90,896 KB
testcase_34 AC 486 ms
86,540 KB
testcase_35 AC 658 ms
91,848 KB
testcase_36 AC 445 ms
81,600 KB
testcase_37 AC 419 ms
81,520 KB
testcase_38 AC 463 ms
84,076 KB
testcase_39 AC 398 ms
87,040 KB
testcase_40 AC 487 ms
90,276 KB
testcase_41 AC 437 ms
87,488 KB
testcase_42 AC 553 ms
86,856 KB
testcase_43 AC 367 ms
80,680 KB
testcase_44 AC 588 ms
89,960 KB
testcase_45 AC 620 ms
86,592 KB
testcase_46 AC 364 ms
85,112 KB
testcase_47 AC 496 ms
88,212 KB
testcase_48 AC 305 ms
81,252 KB
testcase_49 AC 437 ms
87,524 KB
testcase_50 AC 673 ms
87,284 KB
testcase_51 AC 741 ms
91,788 KB
testcase_52 AC 754 ms
92,172 KB
testcase_53 AC 727 ms
91,148 KB
testcase_54 AC 717 ms
91,340 KB
testcase_55 AC 720 ms
92,364 KB
testcase_56 AC 315 ms
89,584 KB
testcase_57 AC 228 ms
89,560 KB
testcase_58 AC 864 ms
96,792 KB
testcase_59 AC 891 ms
95,188 KB
testcase_60 AC 712 ms
95,340 KB
testcase_61 AC 909 ms
96,788 KB
testcase_62 AC 794 ms
95,204 KB
testcase_63 AC 281 ms
91,840 KB
testcase_64 AC 595 ms
91,908 KB
testcase_65 AC 603 ms
93,180 KB
testcase_66 AC 582 ms
93,484 KB
testcase_67 AC 818 ms
95,292 KB
testcase_68 AC 616 ms
92,132 KB
testcase_69 AC 478 ms
92,140 KB
testcase_70 AC 482 ms
92,272 KB
testcase_71 AC 471 ms
94,132 KB
testcase_72 AC 664 ms
92,484 KB
testcase_73 AC 716 ms
93,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def segfunc(x, y):
    return min(x,y)

ide_ele = (1,-1)


class SegTree:
    """
    Segment Tree
    """

    def __init__(self, init_val, segfunc, ide_ele):
        """
        初期化

        init_val: 配列の初期値
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新

        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る

        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

N,M = map(int,input().split())
A = [(-1,i) for i in range(N)]
T = SegTree(A,segfunc,ide_ele)
from collections import defaultdict
d = defaultdict(lambda:0)

for i in range(M):
    
    l,r,t = input().split()
    l = int(l)
    r = int(r)
    
    l -= 1
    f,x = T.query(l,r)
    if f == 1:
        continue
    while f == -1:
        T.update(x,(1,-1))
        d[t] += 1
        f,x = T.query(l,r)
print(d['Y'],d['K'],d['C'])
0