結果

問題 No.2172 SEARCH in the Text Editor
ユーザー 👑 p-adicp-adic
提出日時 2023-06-23 11:08:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 146,016 KB
最終ジャッジ日時 2023-09-13 06:04:31
合計ジャッジ時間 22,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
82,624 KB
testcase_01 AC 96 ms
82,632 KB
testcase_02 AC 97 ms
82,460 KB
testcase_03 AC 462 ms
98,280 KB
testcase_04 AC 453 ms
96,704 KB
testcase_05 AC 458 ms
96,592 KB
testcase_06 AC 237 ms
92,108 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 331 ms
104,616 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 267 ms
94,952 KB
testcase_17 WA -
testcase_18 AC 397 ms
107,612 KB
testcase_19 AC 338 ms
100,588 KB
testcase_20 AC 271 ms
91,596 KB
testcase_21 AC 471 ms
131,300 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 372 ms
105,196 KB
testcase_29 WA -
testcase_30 AC 432 ms
110,348 KB
testcase_31 WA -
testcase_32 AC 581 ms
146,016 KB
testcase_33 AC 563 ms
145,100 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 371 ms
105,220 KB
testcase_41 AC 405 ms
107,232 KB
testcase_42 AC 420 ms
109,500 KB
testcase_43 AC 424 ms
109,216 KB
testcase_44 AC 566 ms
144,912 KB
testcase_45 AC 564 ms
144,808 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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