結果
| 問題 | No.3667 Prefix Count Queries |
| ユーザー |
まぬお
|
| 提出日時 | 2026-09-01 17:16:21 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 196 ms / 2,000 ms |
| + 861µs | |
| コード長 | 1,408 bytes |
| 記録 | |
| コンパイル時間 | 224 ms |
| コンパイル使用メモリ | 96,036 KB |
| 実行使用メモリ | 178,012 KB |
| 最終ジャッジ日時 | 2026-09-01 17:16:30 |
| 合計ジャッジ時間 | 9,018 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 35 |
ソースコード
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]
node[cur] += 1
cur = next_cur(cur, c)
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]])
まぬお