結果

問題 No.1702 count good string
ユーザー ThetaTheta
提出日時 2024-03-28 19:09:21
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2024-03-28 19:09:29
合計ジャッジ時間 7,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,604 KB
testcase_01 AC 44 ms
55,604 KB
testcase_02 AC 51 ms
63,024 KB
testcase_03 AC 87 ms
77,148 KB
testcase_04 AC 86 ms
77,276 KB
testcase_05 AC 86 ms
77,148 KB
testcase_06 AC 101 ms
77,964 KB
testcase_07 AC 84 ms
77,276 KB
testcase_08 AC 97 ms
77,688 KB
testcase_09 AC 85 ms
77,148 KB
testcase_10 AC 83 ms
77,312 KB
testcase_11 AC 113 ms
77,148 KB
testcase_12 AC 92 ms
77,580 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 AC 44 ms
55,604 KB
testcase_46 AC 44 ms
55,604 KB
testcase_47 AC 46 ms
55,604 KB
testcase_48 AC 47 ms
60,916 KB
testcase_49 AC 43 ms
55,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from functools import cache


@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