結果

問題 No.1909 Detect from Substrings
ユーザー rlangevinrlangevin
提出日時 2023-06-12 12:17:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 86,776 KB
実行使用メモリ 159,920 KB
最終ジャッジ日時 2023-09-02 08:00:17
合計ジャッジ時間 10,020 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,324 KB
testcase_01 AC 70 ms
71,332 KB
testcase_02 AC 68 ms
71,468 KB
testcase_03 AC 74 ms
75,124 KB
testcase_04 AC 80 ms
75,336 KB
testcase_05 AC 120 ms
95,928 KB
testcase_06 AC 169 ms
116,680 KB
testcase_07 AC 173 ms
116,828 KB
testcase_08 AC 161 ms
159,920 KB
testcase_09 AC 156 ms
145,148 KB
testcase_10 AC 163 ms
143,672 KB
testcase_11 AC 160 ms
141,812 KB
testcase_12 AC 174 ms
152,276 KB
testcase_13 AC 151 ms
150,624 KB
testcase_14 AC 157 ms
152,044 KB
testcase_15 AC 154 ms
156,952 KB
testcase_16 AC 174 ms
153,680 KB
testcase_17 AC 156 ms
115,672 KB
testcase_18 AC 156 ms
115,864 KB
testcase_19 AC 169 ms
116,888 KB
testcase_20 AC 168 ms
116,676 KB
testcase_21 AC 155 ms
152,856 KB
testcase_22 AC 155 ms
159,328 KB
testcase_23 AC 171 ms
147,536 KB
testcase_24 AC 156 ms
136,832 KB
testcase_25 AC 172 ms
152,788 KB
testcase_26 AC 159 ms
158,208 KB
testcase_27 AC 157 ms
154,976 KB
testcase_28 AC 157 ms
149,868 KB
testcase_29 AC 150 ms
148,132 KB
testcase_30 AC 152 ms
152,896 KB
testcase_31 AC 155 ms
147,268 KB
testcase_32 AC 154 ms
152,856 KB
testcase_33 AC 151 ms
150,548 KB
testcase_34 AC 156 ms
153,164 KB
testcase_35 AC 154 ms
149,948 KB
testcase_36 AC 156 ms
152,908 KB
testcase_37 AC 150 ms
149,816 KB
testcase_38 AC 153 ms
152,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def produce(x, y):
    K = len(x)
    left, right = 0, K-1
    while x[left] == y[left]:
        left += 1
    while x[right] == y[right]:
        right -= 1
    temp1 = x[:left] + [y[left]] + x[left:]
    temp2 = x[:right+1] + [y[right]]+ x[right+1:]
    return [temp1, temp2]
    
def match(x, y):
    now = 0
    temp = y + ["$"]
    for xx in x:
        if temp[now] == xx:
            now += 1
    return now == len(temp) - 1


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

kouho = produce(S[0], S[1])
ans = [1, 1]
for i in range(1, N):
    for j in range(2):
        ans[j] &= match(kouho[j], S[i])

print(sum(ans))
0