結果

問題 No.962 LCPs
ユーザー H3PO4H3PO4
提出日時 2021-07-25 16:15:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 78,232 KB
最終ジャッジ日時 2023-09-28 06:05:26
合計ジャッジ時間 23,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
12,348 KB
testcase_01 AC 48 ms
12,444 KB
testcase_02 AC 49 ms
12,292 KB
testcase_03 AC 47 ms
12,292 KB
testcase_04 AC 48 ms
12,440 KB
testcase_05 AC 48 ms
12,384 KB
testcase_06 AC 47 ms
12,312 KB
testcase_07 AC 48 ms
12,440 KB
testcase_08 AC 47 ms
12,368 KB
testcase_09 WA -
testcase_10 AC 47 ms
12,320 KB
testcase_11 AC 47 ms
12,304 KB
testcase_12 AC 48 ms
12,440 KB
testcase_13 WA -
testcase_14 AC 48 ms
12,360 KB
testcase_15 AC 46 ms
12,320 KB
testcase_16 WA -
testcase_17 AC 561 ms
12,320 KB
testcase_18 AC 389 ms
12,440 KB
testcase_19 AC 402 ms
12,440 KB
testcase_20 AC 332 ms
12,312 KB
testcase_21 AC 329 ms
12,432 KB
testcase_22 AC 298 ms
12,492 KB
testcase_23 AC 301 ms
12,368 KB
testcase_24 AC 284 ms
12,316 KB
testcase_25 AC 279 ms
12,316 KB
testcase_26 AC 271 ms
12,448 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 292 ms
12,316 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 283 ms
12,312 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 364 ms
48,816 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 165 ms
12,444 KB
testcase_58 AC 163 ms
12,432 KB
testcase_59 AC 168 ms
12,364 KB
testcase_60 AC 199 ms
12,380 KB
testcase_61 AC 202 ms
12,348 KB
testcase_62 AC 202 ms
12,480 KB
testcase_63 WA -
testcase_64 AC 677 ms
78,232 KB
testcase_65 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from dataclasses import dataclass, field

N = int(input())
ans = 0

tri = lambda x: x * (x + 1) // 2


@dataclass
class TrieNode:
    num: int
    last: int
    seq: int
    child: dict = field(default_factory=dict)


G = [None] * (2 * 10 ** 5 + 1)
G[0] = TrieNode(num=0, last=0, seq=0)

nodenum = 1
for i in range(N):
    S = input()
    pointer = 0
    for s in S:
        if s not in G[pointer].child:
            G[pointer].child[s] = nodenum
            G[nodenum] = TrieNode(num=nodenum, last=i - 1, seq=0)
            nodenum += 1
        pointer = G[pointer].child[s]
        if G[pointer].last == i - 1:
            G[pointer].seq += 1
            ans += tri(G[pointer].seq)
        else:
            G[pointer].seq = 1
        G[pointer].last = i

print(ans)
0