結果

問題 No.1909 Detect from Substrings
ユーザー tktk_snsntktk_snsn
提出日時 2022-04-22 22:00:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 10,152 KB
最終ジャッジ日時 2023-09-06 08:27:42
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,776 KB
testcase_01 AC 16 ms
7,884 KB
testcase_02 AC 16 ms
7,832 KB
testcase_03 AC 16 ms
7,804 KB
testcase_04 AC 17 ms
8,296 KB
testcase_05 AC 18 ms
8,820 KB
testcase_06 AC 20 ms
9,308 KB
testcase_07 AC 20 ms
9,356 KB
testcase_08 AC 229 ms
10,136 KB
testcase_09 AC 32 ms
10,080 KB
testcase_10 AC 118 ms
9,336 KB
testcase_11 AC 84 ms
9,152 KB
testcase_12 AC 48 ms
9,232 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(S, T):
    N = len(S)
    i = 0
    j = 0
    memo = 0
    while i < N:
        if S[i] == T[j]:
            i += 1
            j += 1
        elif memo == 0:
            memo = (i, T[j])
            i += 1
        else:
            return False, -1
    return True, memo


def main():
    N, M = map(int, input().split())
    S = input()
    T = input()
    U = [input() for _ in range(N - 2)]

    b1, m1 = check(S, T)
    b2, m2 = check(T, S)

    res = 0
    for _ in range(2):
        b, m = check(S, T)
        S, T = T, S
        if b:
            i, c = m
            X = S[:i] + c + S[i:]
            ok = True
            for u in U:
                bb, mm = check(X, u)
                if not bb:
                    ok = False
                    break
            res += ok
    return res


print(main())
0