結果

問題 No.1702 count good string
ユーザー ThetaTheta
提出日時 2024-03-28 19:09:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,327 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 469,696 KB
最終ジャッジ日時 2024-03-28 19:10:01
合計ジャッジ時間 5,288 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
62,408 KB
testcase_01 AC 43 ms
55,604 KB
testcase_02 AC 48 ms
63,024 KB
testcase_03 AC 84 ms
77,148 KB
testcase_04 AC 86 ms
77,276 KB
testcase_05 AC 83 ms
77,148 KB
testcase_06 AC 102 ms
77,964 KB
testcase_07 AC 85 ms
77,276 KB
testcase_08 AC 98 ms
77,688 KB
testcase_09 AC 84 ms
77,148 KB
testcase_10 AC 83 ms
77,312 KB
testcase_11 AC 84 ms
77,148 KB
testcase_12 AC 91 ms
77,580 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import cache
sys.setrecursionlimit(500000)


@cache
def calc_partial_string(
        all_string: str,
        a_idx: int,
        search_string: str,
        s_idx: int) -> int:
    if s_idx == len(search_string):
        if a_idx <= len(all_string):
            return 1
        return 0

    if len(all_string) - a_idx < len(search_string) - s_idx:
        return 0
    if all_string[a_idx] != search_string[s_idx]:
        return calc_partial_string(all_string, a_idx + 1, search_string, s_idx)

    return calc_partial_string(all_string,
                               a_idx + 1,
                               search_string,
                               s_idx) + calc_partial_string(all_string,
                                                            a_idx + 1,
                                                            search_string,
                                                            s_idx + 1)


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


def main():
    N = int(input())
    S = input()
    YUKICODER = "yukicoder"
    T = set(YUKICODER[:idx] + "?" + YUKICODER[idx + 1:] for idx in range(9))
    T.add("yukicoder")

    print(sum(calc_partial_string(S, 0, t_elm, 0) for t_elm in T))


if __name__ == "__main__":
    main()
0