結果

問題 No.1909 Detect from Substrings
ユーザー tassei903tassei903
提出日時 2022-04-22 21:40:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,736 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 134,556 KB
最終ジャッジ日時 2023-09-06 08:01:04
合計ジャッジ時間 9,182 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,324 KB
testcase_01 AC 77 ms
71,096 KB
testcase_02 AC 76 ms
71,444 KB
testcase_03 AC 87 ms
76,184 KB
testcase_04 AC 91 ms
76,148 KB
testcase_05 AC 106 ms
76,660 KB
testcase_06 AC 122 ms
78,332 KB
testcase_07 AC 120 ms
78,428 KB
testcase_08 AC 197 ms
134,556 KB
testcase_09 AC 192 ms
131,844 KB
testcase_10 AC 166 ms
108,964 KB
testcase_11 AC 166 ms
107,596 KB
testcase_12 AC 142 ms
88,968 KB
testcase_13 AC 193 ms
132,608 KB
testcase_14 AC 189 ms
132,292 KB
testcase_15 AC 189 ms
131,068 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 184 ms
131,380 KB
testcase_22 AC 192 ms
131,144 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 192 ms
132,248 KB
testcase_27 AC 188 ms
130,940 KB
testcase_28 AC 192 ms
132,692 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

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 = [input() for i in range(n)]
a = s[0]
b = s[1]
z = []
x = m
y = m+1
ans = 1
for i in range(m):
    if a[i]!=b[i]:
        x = i
        z.append(b[i])
        break
    else:
        z.append(a[i])
for i in range(x+1, m):
    if a[i-1]!=b[i]:
        y = i
        z.append(a[i-1])
        break
    else:
        z.append(a[i-1])
if y == m + 1:
    z.append(a[-1])
for i in range(y, m+1):
    if a[i-1]!=b[i-1]:
        ans = 0
        z.append(a[i-1])
    else:
        z.append(a[i-1])
for i in range(2,n):
    for j in range(m):
        if s[i][j]!=z[j]:
            x = j
            break
    for j in range(x+1,m+1):
        if s[i][j-1]!=z[j]:
            ans = 0
if ans:
    c += 1
        
a,b = b,a
z = []
x = m
y = m+1
ans = 1
for i in range(m):
    if a[i]!=b[i]:
        x = i
        z.append(b[i])
        break
    else:
        z.append(a[i])
for i in range(x+1, m):
    if a[i-1]!=b[i]:
        y = i
        z.append(a[i-1])
        break
    else:
        z.append(a[i-1])
if y == m + 1:
    z.append(a[-1])
for i in range(y, m+1):
    if a[i-1]!=b[i-1]:
        ans = 0
        z.append(a[i-1])
    else:
        z.append(a[i-1])
for i in range(2,n):
    for j in range(m):
        if s[i][j]!=z[j]:
            x = j
            break
    for j in range(x+1,m+1):
        if s[i][j-1]!=z[j]:
            ans = 0
if ans:
    c += 1
print(c)
0