結果
| 問題 | No.1909 Detect from Substrings | 
| コンテスト | |
| ユーザー |  lilictaka | 
| 提出日時 | 2022-04-22 23:30:07 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 973 bytes | 
| コンパイル時間 | 230 ms | 
| コンパイル使用メモリ | 81,980 KB | 
| 実行使用メモリ | 332,868 KB | 
| 最終ジャッジ日時 | 2024-06-24 04:58:10 | 
| 合計ジャッジ時間 | 9,302 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 5 TLE * 1 -- * 30 | 
ソースコード
from collections import deque
N,M = map(int,input().split())
S = []
def tmp(x):
    return ord(x) -ord('a')
for _ in range(N):
    s = list(map(tmp,list(input())))
    S.append(s)
def check(s,t):
    l = 0
    cnt = 0
    for i in range(len(s)):
        if s[i] == t[l]:
            l += 1
        else:
            l += 1
            if cnt:
                return False
            if s[i] == t[l]:
                l+=1
                cnt += 1
            else:
                return False
    return True
def f(m,x,s0):
    s = []
    for i in range(M+1):
        if m == i:
            s.append(x)
        else:
            number = s0.popleft()
            s.append(number)
    return s
def allcheck(t):
    for i in range(N):
        if check(S[i],t):
            pass
        else:
            return False
    return True
ans = 0
for m in range(M+1):
    for x in range(26):
        t = f(m,x,deque(S[0]))
        if allcheck(t):
            ans += 1
print(ans)
            
            
            
        