結果

問題 No.3667 Prefix Count Queries
ユーザー まぬお
提出日時 2026-09-01 17:11:28
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,408 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 224 ms
コンパイル使用メモリ 96,460 KB
実行使用メモリ 177,756 KB
最終ジャッジ日時 2026-09-01 17:11:37
合計ジャッジ時間 9,423 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 5
other AC * 10 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right, insort
from itertools import permutations, combinations, groupby
from heapq import heappop, heappush
import math, sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
def printl(li, sep=" "): print(sep.join(map(str, li)))
def yn(flag): print(Yes if flag else No)
_int = lambda x: int(x)-1
MOD = 998244353 #10**9+7
INF = 1<<60
Yes, No = "Yes", "No"

nxt = [{}]
node = [0]

def next_cur(cur, c):
    if c not in nxt[cur]:
        nxt[cur][c] = len(nxt)
        nxt.append({})
        node.append(0)
    return nxt[cur][c]

def insert(st):
    n = len(st)
    cur = 0
    for i in range(n):
        c = st[i]
        cur = next_cur(cur, c)
        node[cur] += 1
    node[cur] += 1

N = int(input())
for _ in range(N):
    insert(input())

def ctypes(li, types):
    assert len(li) == len(types)
    return [t(a) for a, t in zip(li, types)]
def qinput(*types, indexed = 1):
    li = input().split()
    t = int(li[0])
    if len(li) == 1: return t, None
    elif len(li) == 2: return t, types[t-indexed][0](li[1])
    else: return t, ctypes(li[1:], types[t-indexed])

curs = [0]
for _ in range(int(input())):
    t, qi = qinput([str], [], [])
    if t == 1:
        x = qi
        cur = next_cur(curs[-1], x)
        curs.append(cur)
    elif t == 2:
        curs.pop()
    else:
        print(node[curs[-1]])
0