結果
| 問題 | No.1909 Detect from Substrings | 
| コンテスト | |
| ユーザー |  gew1fw | 
| 提出日時 | 2025-06-12 19:55:18 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                MLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,032 bytes | 
| コンパイル時間 | 286 ms | 
| コンパイル使用メモリ | 82,188 KB | 
| 実行使用メモリ | 848,460 KB | 
| 最終ジャッジ日時 | 2025-06-12 19:55:49 | 
| 合計ジャッジ時間 | 3,942 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 1 MLE * 1 -- * 34 | 
ソースコード
import sys
from collections import defaultdict
def main():
    N, M = map(int, sys.stdin.readline().split())
    S = [sys.stdin.readline().strip() for _ in range(N)]
    if N == 0:
        print(0)
        return
    # Function to generate all possible T's by inserting one character into s
    def generate_T(s):
        possible = set()
        for i in range(len(s)+1):
            for c in 'abcdefghijklmnopqrstuvwxyz':
                new_s = s[:i] + c + s[i:]
                possible.add(new_s)
        return possible
    # Generate all possible T's for each S_i
    T_sets = []
    for s in S:
        T_set = generate_T(s)
        T_sets.append(T_set)
        # Early exit if any T_set is empty
        if not T_set:
            print(0)
            return
    # Compute intersection of all T_sets
    common = T_sets[0]
    for t_set in T_sets[1:]:
        common.intersection_update(t_set)
        if not common:
            print(0)
            return
    print(len(common))
if __name__ == "__main__":
    main()
            
            
            
        