結果

問題 No.1909 Detect from Substrings
ユーザー titan23titan23
提出日時 2022-12-25 19:39:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 80,256 KB
最終ジャッジ日時 2024-04-30 00:17:27
合計ジャッジ時間 5,076 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,968 KB
testcase_01 AC 42 ms
52,096 KB
testcase_02 AC 42 ms
51,840 KB
testcase_03 AC 45 ms
57,600 KB
testcase_04 AC 48 ms
59,648 KB
testcase_05 AC 61 ms
71,680 KB
testcase_06 AC 67 ms
75,904 KB
testcase_07 AC 67 ms
75,904 KB
testcase_08 AC 78 ms
79,872 KB
testcase_09 AC 69 ms
79,360 KB
testcase_10 AC 71 ms
77,824 KB
testcase_11 AC 67 ms
77,056 KB
testcase_12 AC 70 ms
76,288 KB
testcase_13 AC 73 ms
79,232 KB
testcase_14 AC 77 ms
79,104 KB
testcase_15 AC 83 ms
79,616 KB
testcase_16 AC 75 ms
76,416 KB
testcase_17 AC 71 ms
75,776 KB
testcase_18 AC 75 ms
76,032 KB
testcase_19 AC 76 ms
75,776 KB
testcase_20 AC 75 ms
75,648 KB
testcase_21 AC 82 ms
79,872 KB
testcase_22 AC 79 ms
79,872 KB
testcase_23 AC 76 ms
77,952 KB
testcase_24 AC 74 ms
77,440 KB
testcase_25 AC 75 ms
76,672 KB
testcase_26 AC 79 ms
79,744 KB
testcase_27 AC 83 ms
79,616 KB
testcase_28 AC 82 ms
78,976 KB
testcase_29 AC 85 ms
79,616 KB
testcase_30 AC 85 ms
79,616 KB
testcase_31 AC 82 ms
78,848 KB
testcase_32 AC 85 ms
80,256 KB
testcase_33 AC 83 ms
79,360 KB
testcase_34 AC 85 ms
80,000 KB
testcase_35 AC 88 ms
79,872 KB
testcase_36 AC 89 ms
79,872 KB
testcase_37 AC 86 ms
79,232 KB
testcase_38 AC 88 ms
80,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

#  -----------------------  #

n, m = map(int, input().split())
S = [input() for _ in range(n)]
ans = 0
s = S[0]
t = S[1]
j = -1
for i in range(m):
  if s[i] != t[i]:
    j = i
    break
T1 = s[:j] + s[j] + t[j:]
T2 = s[:j] + t[j] + s[j:]

def isok(T, s):
  i = 0
  j = 0
  diff = 0
  while i < m and j < m+1:
    if s[i] != T[j]:
      diff += 1
      if diff == 2:
        break
      i -= 1
    i += 1
    j += 1
  else:
    return True
  return False

# T1?
for s in S:
  if not isok(T1, s):
    break
else:
  ans += 1
  
# T2?
for s in S:
  if not isok(T2, s):
    break
else:
  ans += 1
  
print(ans)

0