結果

問題 No.1909 Detect from Substrings
ユーザー ニックネームニックネーム
提出日時 2022-04-22 22:18:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 689 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 10,696 KB
最終ジャッジ日時 2023-09-06 08:51:32
合計ジャッジ時間 2,803 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,884 KB
testcase_01 AC 16 ms
7,888 KB
testcase_02 AC 16 ms
7,948 KB
testcase_03 AC 16 ms
7,816 KB
testcase_04 AC 17 ms
8,192 KB
testcase_05 AC 19 ms
8,680 KB
testcase_06 AC 21 ms
9,316 KB
testcase_07 AC 21 ms
9,228 KB
testcase_08 AC 20 ms
10,656 KB
testcase_09 AC 20 ms
10,668 KB
testcase_10 AC 19 ms
9,564 KB
testcase_11 AC 18 ms
9,420 KB
testcase_12 AC 18 ms
9,332 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
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 #

n, m = map(int, input().split())
s = {input() for _ in range(n)}; t = s.pop()
l = []; r = []; lrl = set(); lrr = set()
flag = True; ans = 0
for v in s:
    a = b = False
    if v[1:] == t[:-1]: a = True
    if v[:-1] == t[1:]: b = True
    if a and b: lrl.add(v[0]); lrr.add(v[-1])
    elif a: l.append(v[0])
    elif b: r.append(v[-1])
    else: flag = False
if flag and len(l)+len(r) <= 1:
    if l:
        if not lrl or len(lrl) == 1 and lrl.pop() == l[0]: ans = 1
    elif r:
        if not lrr or len(lrr) == 1 and lrr.pop() == r[0]: ans = 1
    else:
        if not lrl: ans = 52
        else:
            if len(lrl) == 1: ans += 1
            if len(lrr) == 1: ans += 1
print(ans)
0