結果

問題 No.1909 Detect from Substrings
ユーザー 👑 colognecologne
提出日時 2022-04-22 21:43:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 10,376 KB
最終ジャッジ日時 2023-09-06 08:04:26
合計ジャッジ時間 9,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 16 ms
7,896 KB
testcase_03 AC 16 ms
7,840 KB
testcase_04 AC 21 ms
8,252 KB
testcase_05 AC 48 ms
8,564 KB
testcase_06 AC 55 ms
9,368 KB
testcase_07 AC 58 ms
9,392 KB
testcase_08 AC 275 ms
10,072 KB
testcase_09 AC 163 ms
10,060 KB
testcase_10 AC 99 ms
9,740 KB
testcase_11 AC 137 ms
9,696 KB
testcase_12 AC 117 ms
9,284 KB
testcase_13 AC 178 ms
10,116 KB
testcase_14 AC 216 ms
10,056 KB
testcase_15 AC 294 ms
10,244 KB
testcase_16 AC 147 ms
9,372 KB
testcase_17 AC 125 ms
9,180 KB
testcase_18 AC 122 ms
9,312 KB
testcase_19 AC 122 ms
9,448 KB
testcase_20 AC 122 ms
9,268 KB
testcase_21 AC 284 ms
10,224 KB
testcase_22 AC 284 ms
10,152 KB
testcase_23 AC 165 ms
9,388 KB
testcase_24 AC 160 ms
9,360 KB
testcase_25 AC 167 ms
9,320 KB
testcase_26 AC 260 ms
10,376 KB
testcase_27 AC 315 ms
10,084 KB
testcase_28 AC 268 ms
10,084 KB
testcase_29 AC 284 ms
10,340 KB
testcase_30 AC 317 ms
10,152 KB
testcase_31 AC 270 ms
10,156 KB
testcase_32 AC 315 ms
10,328 KB
testcase_33 AC 251 ms
10,184 KB
testcase_34 AC 319 ms
10,200 KB
testcase_35 AC 276 ms
10,328 KB
testcase_36 AC 317 ms
10,060 KB
testcase_37 AC 277 ms
10,272 KB
testcase_38 AC 315 ms
10,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, M = map(int, input().split())
    S = [input() for i in range(N)]

    def subseq(s, x):
        p = 0
        for c in s:
            if p < len(x) and x[p] == c:
                p += 1
        return p == len(x)

    def check(x):
        for s in S:
            if not subseq(x, s):
                return False
        return True

    for i in range(M):
        for j in range(N):
            if S[0][i] != S[j][i]:
                ans = 0
                ans += check(S[0][:i] + S[0][i] + S[j][i:])
                ans += check(S[j][:i] + S[j][i] + S[0][i:])
                print(ans)
                return


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