結果
| 問題 | No.1909 Detect from Substrings | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:52:35 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 962 bytes | 
| コンパイル時間 | 149 ms | 
| コンパイル使用メモリ | 82,248 KB | 
| 実行使用メモリ | 279,376 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:53:28 | 
| 合計ジャッジ時間 | 6,542 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 2 TLE * 1 -- * 33 | 
ソースコード
def main():
    import sys
    from collections import defaultdict
    N, M = map(int, sys.stdin.readline().split())
    S = [sys.stdin.readline().strip() for _ in range(N)]
    possible = None
    for s in S:
        candidates = defaultdict(int)
        for i in range(M + 1):
            for c in 'abcdefghijklmnopqrstuvwxyz':
                t = s[:i] + c + s[i:]
                candidates[t] += 1
        if possible is None:
            possible = candidates
        else:
            new_possible = defaultdict(int)
            for t, cnt in possible.items():
                if t in candidates:
                    new_possible[t] = cnt + 1
            possible = new_possible
            if not possible:
                break
    if possible is None:
        print(0)
    else:
        count = 0
        for t, cnt in possible.items():
            if cnt == N:
                count += 1
        print(count)
if __name__ == "__main__":
    main()
            
            
            
        