結果
問題 | No.2388 At Least K-Characters |
ユーザー | cleantted |
提出日時 | 2023-07-22 00:12:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 572 ms / 4,000 ms |
コード長 | 2,117 bytes |
コンパイル時間 | 146 ms |
コンパイル使用メモリ | 82,668 KB |
実行使用メモリ | 98,040 KB |
最終ジャッジ日時 | 2024-07-05 04:12:21 |
合計ジャッジ時間 | 15,152 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 170 ms
90,204 KB |
testcase_01 | AC | 167 ms
90,188 KB |
testcase_02 | AC | 168 ms
90,552 KB |
testcase_03 | AC | 167 ms
90,260 KB |
testcase_04 | AC | 165 ms
90,312 KB |
testcase_05 | AC | 160 ms
90,304 KB |
testcase_06 | AC | 160 ms
90,048 KB |
testcase_07 | AC | 155 ms
90,512 KB |
testcase_08 | AC | 154 ms
90,312 KB |
testcase_09 | AC | 161 ms
89,872 KB |
testcase_10 | AC | 158 ms
89,852 KB |
testcase_11 | AC | 167 ms
90,388 KB |
testcase_12 | AC | 161 ms
89,848 KB |
testcase_13 | AC | 175 ms
91,076 KB |
testcase_14 | AC | 176 ms
91,200 KB |
testcase_15 | AC | 172 ms
91,024 KB |
testcase_16 | AC | 487 ms
97,676 KB |
testcase_17 | AC | 444 ms
97,816 KB |
testcase_18 | AC | 480 ms
97,892 KB |
testcase_19 | AC | 491 ms
97,620 KB |
testcase_20 | AC | 500 ms
97,856 KB |
testcase_21 | AC | 525 ms
98,040 KB |
testcase_22 | AC | 515 ms
97,960 KB |
testcase_23 | AC | 572 ms
97,820 KB |
testcase_24 | AC | 510 ms
97,776 KB |
testcase_25 | AC | 496 ms
97,956 KB |
testcase_26 | AC | 526 ms
97,564 KB |
testcase_27 | AC | 515 ms
97,816 KB |
testcase_28 | AC | 523 ms
97,692 KB |
testcase_29 | AC | 513 ms
97,920 KB |
testcase_30 | AC | 499 ms
97,924 KB |
testcase_31 | AC | 499 ms
97,988 KB |
testcase_32 | AC | 494 ms
97,740 KB |
testcase_33 | AC | 494 ms
98,040 KB |
testcase_34 | AC | 511 ms
97,676 KB |
testcase_35 | AC | 531 ms
97,772 KB |
testcase_36 | AC | 528 ms
97,564 KB |
ソースコード
# import bisect import copy import heapq import itertools import math import operator import random import sys from bisect import bisect, bisect_left, bisect_right, insort from collections import Counter, deque from fractions import Fraction from functools import cmp_to_key, lru_cache, partial from inspect import currentframe from math import ceil, gcd, log10, pi, sqrt from typing import Iterable, Iterator, List, Tuple, TypeVar, Union # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') # import string # import networkx as nx input = sys.stdin.readline sys.setrecursionlimit(10000000) # mod = 10 ** 9 + 7 mod = 998244353 # mod = 1 << 128 # mod = 10 ** 30 + 1 INF = 1 << 61 DIFF = 10 ** -9 DX = [1, 0, -1, 0, 1, 1, -1, -1] DY = [0, 1, 0, -1, 1, -1, 1, -1] def read_values(): return tuple(map(int, input().split())) def read_index(): return tuple(map(lambda x: int(x) - 1, input().split())) def read_list(): return list(read_values()) def read_lists(N): return [read_list() for _ in range(N)] def dprint(*values): print(*values, file=sys.stderr) def dprint2(*values): names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} dprint(", ".join(f"{names.get(id(value), '???')}={repr(value)}" for value in values)) def main(): N, M, K = read_values() S = input().strip() S = [ord(s) - ord("a") for s in S] T = set() dp = [0] * 27 res = 0 for i in range(M): dp2 = [0] * 27 if i < N: for s in range(S[i]): if s in T: dp2[len(T)] += 1 else: dp2[len(T) + 1] += 1 T.add(S[i]) if len(T) >= K: res += 1 res %= mod for d, t in enumerate(dp): dp2[d] += d * t % mod dp2[d] %= mod if d < 26: dp2[d + 1] += t * (26 - d) % mod dp2[d + 1] %= mod res += sum(dp2[K:]) % mod res %= mod dp = dp2 if len(T) >= K: res -= 1 res %= mod print(res) if __name__ == "__main__": main()