結果

問題 No.2172 SEARCH in the Text Editor
ユーザー 👑 p-adicp-adic
提出日時 2023-06-23 11:03:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 145,520 KB
最終ジャッジ日時 2023-09-13 05:58:16
合計ジャッジ時間 21,836 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
86,836 KB
testcase_01 AC 82 ms
86,692 KB
testcase_02 AC 83 ms
86,876 KB
testcase_03 AC 373 ms
94,956 KB
testcase_04 AC 380 ms
94,880 KB
testcase_05 AC 385 ms
95,072 KB
testcase_06 AC 207 ms
90,768 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 293 ms
106,372 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 233 ms
94,472 KB
testcase_17 WA -
testcase_18 AC 362 ms
106,920 KB
testcase_19 AC 292 ms
97,716 KB
testcase_20 AC 225 ms
91,416 KB
testcase_21 AC 436 ms
132,232 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 328 ms
104,624 KB
testcase_29 WA -
testcase_30 AC 376 ms
107,404 KB
testcase_31 WA -
testcase_32 AC 542 ms
145,520 KB
testcase_33 AC 522 ms
145,228 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 330 ms
104,884 KB
testcase_41 AC 347 ms
104,976 KB
testcase_42 AC 374 ms
107,880 KB
testcase_43 AC 377 ms
107,772 KB
testcase_44 AC 513 ms
144,332 KB
testcase_45 AC 513 ms
144,352 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

I,R=input,range
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)
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+ord(T[i])*p[i])%Q
	B[i]=v=(ord(T[L-1-i])+v*P)%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=ord(c[i]),(ord(c[l-1-i])+v*P)%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-ord(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