結果
問題 | No.2020 Sum of Common Prefix Length |
ユーザー |
👑 |
提出日時 | 2022-07-22 22:13:59 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 846 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 83,200 KB |
最終ジャッジ日時 | 2024-07-04 06:39:27 |
合計ジャッジ時間 | 4,861 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 4 TLE * 1 -- * 30 |
ソースコード
class Node: def __init__(self): self.nex = {} self.ind = [] n = int(input()) V0 = Node() Vs = [None] * n ans = [0] * n for i in range(n): S = input() V = V0 for s in S: if s not in V.nex: V.nex[s] = Node() V = V.nex[s] ans[i] += 1 for j in V.ind: ans[i] += 1 ans[j] += 1 V.ind.append(i) Vs[i] = V Q = int(input()) for _ in range(Q): query = input().split() if query[0] == "1": x = int(query[1]) - 1 s = query[2] V = Vs[x] if s not in V.nex: V.nex[s] = Node() V = V.nex[s] ans[x] += 1 for j in V.ind: ans[x] += 1 ans[j] += 1 V.ind.append(i) Vs[x] = V else: x = int(query[1]) - 1 print(ans[x])