結果

問題 No.1909 Detect from Substrings
ユーザー mkawa2mkawa2
提出日時 2022-04-22 21:29:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,563 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 136,048 KB
最終ジャッジ日時 2023-09-06 07:47:45
合計ジャッジ時間 7,959 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,468 KB
testcase_01 AC 76 ms
71,540 KB
testcase_02 AC 73 ms
71,376 KB
testcase_03 AC 81 ms
75,700 KB
testcase_04 AC 85 ms
76,424 KB
testcase_05 AC 108 ms
76,860 KB
testcase_06 AC 115 ms
77,264 KB
testcase_07 AC 113 ms
77,024 KB
testcase_08 AC 154 ms
120,560 KB
testcase_09 AC 91 ms
79,472 KB
testcase_10 AC 124 ms
96,048 KB
testcase_11 AC 98 ms
86,396 KB
testcase_12 AC 132 ms
86,056 KB
testcase_13 AC 147 ms
121,844 KB
testcase_14 AC 150 ms
117,848 KB
testcase_15 AC 164 ms
122,560 KB
testcase_16 AC 152 ms
85,960 KB
testcase_17 AC 149 ms
77,704 KB
testcase_18 AC 155 ms
77,412 KB
testcase_19 AC 153 ms
77,484 KB
testcase_20 AC 152 ms
77,044 KB
testcase_21 AC 164 ms
122,104 KB
testcase_22 AC 169 ms
124,452 KB
testcase_23 AC 151 ms
91,408 KB
testcase_24 AC 152 ms
91,580 KB
testcase_25 AC 154 ms
85,868 KB
testcase_26 AC 164 ms
119,572 KB
testcase_27 AC 172 ms
122,364 KB
testcase_28 AC 158 ms
122,252 KB
testcase_29 AC 199 ms
135,992 KB
testcase_30 WA -
testcase_31 AC 206 ms
135,960 KB
testcase_32 WA -
testcase_33 AC 201 ms
135,972 KB
testcase_34 WA -
testcase_35 AC 201 ms
135,988 KB
testcase_36 WA -
testcase_37 AC 201 ms
136,048 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 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])
if check(t): tt.add("".join(t))
t = compare(ss[1], ss[0])
if check(t): tt.add("".join(t))
print(len(tt))
0