結果

問題 No.1909 Detect from Substrings
ユーザー chineristACchineristAC
提出日時 2022-02-06 22:06:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 584 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 80,704 KB
最終ジャッジ日時 2023-09-04 00:26:37
合計ジャッジ時間 7,623 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,412 KB
testcase_01 AC 73 ms
71,212 KB
testcase_02 AC 73 ms
71,204 KB
testcase_03 AC 76 ms
75,584 KB
testcase_04 AC 78 ms
75,260 KB
testcase_05 AC 89 ms
77,196 KB
testcase_06 AC 97 ms
77,416 KB
testcase_07 AC 98 ms
77,576 KB
testcase_08 AC 107 ms
80,604 KB
testcase_09 AC 109 ms
80,284 KB
testcase_10 AC 98 ms
78,400 KB
testcase_11 AC 95 ms
78,212 KB
testcase_12 AC 95 ms
77,368 KB
testcase_13 AC 101 ms
79,948 KB
testcase_14 AC 103 ms
79,968 KB
testcase_15 AC 109 ms
80,496 KB
testcase_16 AC 98 ms
77,032 KB
testcase_17 AC 95 ms
76,764 KB
testcase_18 AC 99 ms
77,472 KB
testcase_19 AC 104 ms
77,772 KB
testcase_20 AC 104 ms
77,728 KB
testcase_21 AC 109 ms
80,500 KB
testcase_22 AC 105 ms
80,704 KB
testcase_23 AC 99 ms
78,740 KB
testcase_24 AC 99 ms
78,792 KB
testcase_25 AC 95 ms
77,048 KB
testcase_26 AC 100 ms
80,672 KB
testcase_27 AC 107 ms
80,444 KB
testcase_28 AC 107 ms
79,824 KB
testcase_29 AC 105 ms
80,512 KB
testcase_30 AC 106 ms
80,440 KB
testcase_31 AC 104 ms
79,864 KB
testcase_32 AC 106 ms
80,532 KB
testcase_33 AC 107 ms
80,172 KB
testcase_34 AC 108 ms
80,456 KB
testcase_35 AC 107 ms
80,680 KB
testcase_36 AC 110 ms
80,620 KB
testcase_37 AC 105 ms
79,972 KB
testcase_38 AC 107 ms
80,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def check(N,M,S,T):
    for i in range(N):
        search = 0
        for j in range(M+1):
            if search==M:
                break
            if S[i][search]==T[j]:
                search += 1
        if search!=M:
            return 0
    return 1


def solve(N,M,S):
    for j in range(M):
        if S[0][j]!=S[1][j]:
            T0 = S[0][:j] + S[1][j] + S[0][j:]
            T1 = S[1][:j] + S[0][j] + S[1][j:]
            res = check(N,M,S,T0) + check(N,M,S,T1)
            return res

N,M = map(int,input().split())
S = [input() for _ in range(N)]
print(solve(N,M,S))

0