結果

問題 No.945 YKC饅頭
ユーザー rlangevinrlangevin
提出日時 2023-12-07 00:10:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,383 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 82,040 KB
最終ジャッジ日時 2023-12-07 00:11:06
合計ジャッジ時間 9,090 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 48 ms
64,068 KB
testcase_03 AC 61 ms
70,676 KB
testcase_04 AC 48 ms
64,060 KB
testcase_05 AC 53 ms
66,120 KB
testcase_06 AC 64 ms
70,672 KB
testcase_07 AC 60 ms
68,588 KB
testcase_08 AC 56 ms
68,248 KB
testcase_09 AC 53 ms
66,516 KB
testcase_10 AC 61 ms
70,684 KB
testcase_11 AC 56 ms
68,596 KB
testcase_12 AC 57 ms
68,592 KB
testcase_13 AC 65 ms
70,680 KB
testcase_14 AC 67 ms
72,776 KB
testcase_15 AC 43 ms
61,712 KB
testcase_16 AC 48 ms
64,060 KB
testcase_17 AC 53 ms
66,532 KB
testcase_18 AC 61 ms
68,588 KB
testcase_19 AC 50 ms
64,064 KB
testcase_20 AC 47 ms
61,964 KB
testcase_21 AC 52 ms
66,532 KB
testcase_22 AC 66 ms
70,688 KB
testcase_23 AC 65 ms
70,680 KB
testcase_24 AC 61 ms
68,584 KB
testcase_25 AC 70 ms
72,764 KB
testcase_26 AC 77 ms
74,288 KB
testcase_27 AC 43 ms
59,084 KB
testcase_28 AC 43 ms
61,192 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 36 ms
53,460 KB
testcase_31 AC 807 ms
77,952 KB
testcase_32 AC 558 ms
82,040 KB
testcase_33 TLE -
testcase_34 -- -
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

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]
        self.nex = [i + 1 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        v = max(self.nex[x], self.nex[y])
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]
            self.nex[x] = self.nex[y] = v

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


N, M = map(int, input().split())
ans = [-1] * N
U = UnionFind(N + 1)
for i in range(M):
    L, R, T = input().split()
    L, R = int(L) - 1, int(R) - 1
    now = L
    while now <= R:
        if ans[now] == -1:
            ans[now] = T
        temp = U.nex[now]
        if now != R:
            U.union(now, now + 1)
        now = temp
    
print(ans.count("Y"), ans.count("K"), ans.count("C"))
0