結果

問題 No.1909 Detect from Substrings
ユーザー mkawa2mkawa2
提出日時 2022-04-22 21:35:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 135,868 KB
最終ジャッジ日時 2023-09-06 07:54:56
合計ジャッジ時間 8,056 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,264 KB
testcase_01 AC 75 ms
71,332 KB
testcase_02 AC 74 ms
71,256 KB
testcase_03 AC 81 ms
75,672 KB
testcase_04 AC 85 ms
76,256 KB
testcase_05 AC 103 ms
76,860 KB
testcase_06 AC 109 ms
77,252 KB
testcase_07 AC 109 ms
76,652 KB
testcase_08 AC 145 ms
120,296 KB
testcase_09 AC 87 ms
79,696 KB
testcase_10 AC 125 ms
95,664 KB
testcase_11 AC 97 ms
86,488 KB
testcase_12 AC 128 ms
85,708 KB
testcase_13 AC 145 ms
121,756 KB
testcase_14 AC 150 ms
117,620 KB
testcase_15 AC 157 ms
122,080 KB
testcase_16 AC 147 ms
85,764 KB
testcase_17 AC 145 ms
77,596 KB
testcase_18 AC 148 ms
77,324 KB
testcase_19 AC 145 ms
77,288 KB
testcase_20 AC 147 ms
77,104 KB
testcase_21 AC 162 ms
122,000 KB
testcase_22 AC 161 ms
124,272 KB
testcase_23 AC 144 ms
91,224 KB
testcase_24 AC 146 ms
91,208 KB
testcase_25 AC 150 ms
85,948 KB
testcase_26 AC 161 ms
119,264 KB
testcase_27 AC 168 ms
122,004 KB
testcase_28 AC 156 ms
122,084 KB
testcase_29 AC 198 ms
135,760 KB
testcase_30 WA -
testcase_31 AC 201 ms
135,740 KB
testcase_32 WA -
testcase_33 AC 202 ms
135,820 KB
testcase_34 WA -
testcase_35 AC 196 ms
135,868 KB
testcase_36 WA -
testcase_37 AC 195 ms
135,736 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

def compare(s, t):
    a = b = 0
    res = []
    for i in range(m-1):
        if s[i+a] != t[i+b]:
            if a == 0 and s[i+1] == t[i]:
                res.append(s[i])
                a = 1
            elif a == 1 and b == 0 and (s[i+1] == t[i+1] or i+1 == m):
                res.append(t[i])
                b = 1
            else:
                return ""
        res.append(s[i+a])
    if a == 0: res.append(s[-1])
    if b == 0: res.append(t[-1])
    return res

def check(t):
    if not t: return False
    for s in ss[2:]:
        if ng(s, t): return False
    return True

def ng(s, t):
    t = iter(t)
    for c in s:
        if c not in t: return True
    return False

n, m = LI()
ss = [SI() for _ in range(n)]
tt = set()

t = compare(ss[0], ss[1])
# pDB(t)
if check(t): tt.add("".join(t))

t = compare(ss[1], ss[0])
# pDB(t)
if check(t): tt.add("".join(t))

print(len(tt))
0