結果

問題 No.1909 Detect from Substrings
ユーザー titiatitia
提出日時 2022-04-23 01:26:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 626 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 10,972 KB
実行使用メモリ 10,964 KB
最終ジャッジ日時 2023-09-06 12:20:51
合計ジャッジ時間 14,547 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,880 KB
testcase_01 AC 16 ms
7,872 KB
testcase_02 AC 16 ms
7,836 KB
testcase_03 AC 17 ms
8,212 KB
testcase_04 AC 29 ms
8,268 KB
testcase_05 AC 90 ms
8,800 KB
testcase_06 AC 98 ms
9,132 KB
testcase_07 AC 101 ms
9,320 KB
testcase_08 AC 351 ms
10,740 KB
testcase_09 AC 173 ms
10,720 KB
testcase_10 AC 228 ms
9,696 KB
testcase_11 AC 145 ms
9,748 KB
testcase_12 AC 212 ms
9,552 KB
testcase_13 AC 348 ms
10,676 KB
testcase_14 AC 297 ms
10,708 KB
testcase_15 AC 452 ms
10,948 KB
testcase_16 AC 320 ms
9,624 KB
testcase_17 AC 243 ms
9,100 KB
testcase_18 AC 243 ms
9,212 KB
testcase_19 AC 242 ms
9,236 KB
testcase_20 AC 240 ms
9,208 KB
testcase_21 AC 474 ms
10,836 KB
testcase_22 AC 445 ms
10,540 KB
testcase_23 AC 321 ms
9,788 KB
testcase_24 AC 292 ms
9,740 KB
testcase_25 AC 306 ms
9,492 KB
testcase_26 AC 354 ms
10,964 KB
testcase_27 AC 472 ms
10,640 KB
testcase_28 AC 413 ms
10,532 KB
testcase_29 AC 531 ms
10,608 KB
testcase_30 AC 626 ms
10,740 KB
testcase_31 AC 497 ms
10,644 KB
testcase_32 AC 526 ms
10,952 KB
testcase_33 AC 488 ms
10,696 KB
testcase_34 AC 529 ms
10,572 KB
testcase_35 AC 500 ms
10,616 KB
testcase_36 AC 527 ms
10,676 KB
testcase_37 AC 505 ms
10,644 KB
testcase_38 AC 526 ms
10,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N,M=map(int,input().split())
S=[input().strip() for i in range(N)]

for i in range(M):
    if S[0][i]!=S[1][i]:
        T1=S[0][:i]+S[1][i]+S[0][i:]
        T2=S[1][:i]+S[0][i]+S[1][i:]
        break

ANS=0

for i in range(N):
    s=S[i]
    ind2=0
    c=0
    for ind in range(M):
        if s[ind]==T1[ind2]:
            ind2+=1
        else:
            c+=1
            if s[ind]==T1[ind2+1]:
                ind2+=2
            else:
                c=100
                break
    if c>=2:
        break
    
else:
    ANS+=1

    
for i in range(N):
    s=S[i]
    ind2=0
    c=0
    for ind in range(M):
        if s[ind]==T2[ind2]:
            ind2+=1
        else:
            c+=1
            if s[ind]==T2[ind2+1]:
                ind2+=2
            else:
                c=100
                break
    if c>=2:
        break
    
else:
    ANS+=1

print(ANS)

    

0