結果

問題 No.2172 SEARCH in the Text Editor
ユーザー 👑 p-adicp-adic
提出日時 2023-06-23 12:56:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 605 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 86,872 KB
最終ジャッジ日時 2023-09-13 07:49:41
合計ジャッジ時間 6,968 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
86,468 KB
testcase_01 AC 83 ms
86,872 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R,O=input,range,ord
N=int(I())
T=I()
P=998244353
Q=10**9+7
p=[1]
for n in R(11**5):p+=[p[-1]*P%Q]
p[-1]=pow(P,-1,Q)
L=len(T)
t=sum(O(T[i])*p[i]for i in R(L))%Q
def C(s):
	a=u=0
	for i in R(len(s)):
		if i<L:u=(u+O(s[i])*p[i])%Q
		else:u=((u-O(s[i-L]))*p[-1]+O(s[i])*p[L-1])%Q
		a+=u==t
	return a
S=[]
for n in R(N):
	X=I().split()
	s,U,V=X[0],[0]*L,[0]*L
	l=len(s)
	if s=="~":
		U,V=S[int(X[1])-1],S[int(X[2])-1]
		S+=[[(U[0]+V[0]*U[1])%Q,U[1]*V[1]%Q,(U[2]+V[2])[:L-1],(U[3]+C(U[4]+V[2])+V[3])%P,(U[4]+V[4])[1-L:]]]
	else:S+=[[sum(O(s[i])*p[i]for i in R(l))%Q,p[l],s[:L-1],C(s),s[1-L:]]]
print(S[-1][3])
0