結果
問題 |
No.1909 Detect from Substrings
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:52:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 962 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 286,000 KB |
最終ジャッジ日時 | 2025-06-12 14:55:15 |
合計ジャッジ時間 | 7,056 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()