結果

問題 No.1909 Detect from Substrings
ユーザー tassei903tassei903
提出日時 2022-04-22 21:57:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 160,876 KB
最終ジャッジ日時 2023-09-06 08:22:50
合計ジャッジ時間 8,345 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,324 KB
testcase_01 AC 71 ms
71,380 KB
testcase_02 AC 72 ms
71,296 KB
testcase_03 AC 79 ms
75,992 KB
testcase_04 AC 87 ms
76,524 KB
testcase_05 AC 119 ms
88,372 KB
testcase_06 AC 161 ms
116,428 KB
testcase_07 AC 166 ms
116,472 KB
testcase_08 AC 189 ms
160,876 KB
testcase_09 AC 194 ms
146,324 KB
testcase_10 AC 185 ms
135,884 KB
testcase_11 AC 176 ms
134,212 KB
testcase_12 AC 170 ms
123,196 KB
testcase_13 AC 186 ms
151,868 KB
testcase_14 AC 189 ms
153,428 KB
testcase_15 AC 188 ms
157,912 KB
testcase_16 AC 169 ms
124,664 KB
testcase_17 AC 148 ms
105,212 KB
testcase_18 AC 150 ms
105,268 KB
testcase_19 AC 151 ms
105,184 KB
testcase_20 AC 152 ms
105,192 KB
testcase_21 AC 187 ms
154,136 KB
testcase_22 AC 186 ms
160,836 KB
testcase_23 AC 180 ms
132,064 KB
testcase_24 AC 177 ms
128,828 KB
testcase_25 AC 167 ms
123,688 KB
testcase_26 AC 190 ms
159,520 KB
testcase_27 AC 190 ms
156,412 KB
testcase_28 AC 190 ms
150,812 KB
testcase_29 AC 188 ms
149,084 KB
testcase_30 AC 186 ms
154,112 KB
testcase_31 AC 186 ms
148,584 KB
testcase_32 AC 188 ms
154,084 KB
testcase_33 AC 182 ms
151,856 KB
testcase_34 AC 190 ms
154,104 KB
testcase_35 AC 186 ms
151,256 KB
testcase_36 AC 184 ms
154,176 KB
testcase_37 AC 184 ms
150,984 KB
testcase_38 AC 188 ms
154,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
c = 0
n,m = na()
s = [list(input()) for i in range(n)]
a = s[0]
b = s[1]

for i in range(m):
    if a[i]!=b[i]:
        l = i
        break
for i in range(m-1,-1,-1):
    if a[i]!=b[i]:
        r = i
        break
x = a[:l]+[b[l]]+a[l:]
y = a[:r+1]+[b[r]]+b[r+1:]
ans = 1
for i in range(n):
    t = m+1
    for j in range(m):
        if s[i][j]!=x[j]:
            t = j
            break
    for j in range(t+1,m+1):
        if s[i][j-1]!=x[j]:
            ans = 0
if ans:
    c += 1
ans = 1
for i in range(n):
    t = m+1
    for j in range(m):
        if s[i][j]!=y[j]:
            t = j
            #print(i, j)
            break
    for j in range(t+1,m+1):
        if s[i][j-1]!=y[j]:
            ans = 0
            #print(i,t)
if ans:
    c += 1
print(c)
0