結果

問題 No.1909 Detect from Substrings
ユーザー mkawa2mkawa2
提出日時 2022-04-22 21:24:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 136,160 KB
最終ジャッジ日時 2023-09-06 07:40:27
合計ジャッジ時間 8,172 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,296 KB
testcase_01 AC 79 ms
71,400 KB
testcase_02 AC 87 ms
71,560 KB
testcase_03 AC 88 ms
75,904 KB
testcase_04 AC 93 ms
76,256 KB
testcase_05 AC 115 ms
76,892 KB
testcase_06 AC 118 ms
77,344 KB
testcase_07 AC 115 ms
77,176 KB
testcase_08 AC 156 ms
120,512 KB
testcase_09 AC 89 ms
79,568 KB
testcase_10 AC 127 ms
95,852 KB
testcase_11 AC 101 ms
86,464 KB
testcase_12 AC 134 ms
85,920 KB
testcase_13 AC 146 ms
121,948 KB
testcase_14 AC 149 ms
117,976 KB
testcase_15 AC 164 ms
122,220 KB
testcase_16 AC 155 ms
86,064 KB
testcase_17 AC 157 ms
77,868 KB
testcase_18 AC 159 ms
77,412 KB
testcase_19 AC 160 ms
77,296 KB
testcase_20 AC 155 ms
77,080 KB
testcase_21 AC 165 ms
122,224 KB
testcase_22 AC 171 ms
124,508 KB
testcase_23 AC 155 ms
91,396 KB
testcase_24 AC 151 ms
91,540 KB
testcase_25 AC 151 ms
86,120 KB
testcase_26 AC 167 ms
119,420 KB
testcase_27 AC 171 ms
122,300 KB
testcase_28 AC 155 ms
122,164 KB
testcase_29 AC 202 ms
135,876 KB
testcase_30 WA -
testcase_31 AC 203 ms
136,132 KB
testcase_32 WA -
testcase_33 AC 205 ms
135,964 KB
testcase_34 WA -
testcase_35 AC 200 ms
136,160 KB
testcase_36 WA -
testcase_37 AC 203 ms
135,920 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])
    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