結果

問題 No.2172 SEARCH in the Text Editor
ユーザー 👑 p-adicp-adic
提出日時 2023-06-23 12:16:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 817 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 148,948 KB
最終ジャッジ日時 2023-09-13 07:10:50
合計ジャッジ時間 19,937 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
87,104 KB
testcase_01 AC 86 ms
86,780 KB
testcase_02 AC 89 ms
86,836 KB
testcase_03 AC 390 ms
100,268 KB
testcase_04 AC 388 ms
100,588 KB
testcase_05 AC 386 ms
100,404 KB
testcase_06 AC 214 ms
92,288 KB
testcase_07 AC 229 ms
90,992 KB
testcase_08 AC 214 ms
90,024 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 292 ms
107,592 KB
testcase_12 AC 263 ms
96,304 KB
testcase_13 AC 292 ms
99,792 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 243 ms
97,036 KB
testcase_17 AC 261 ms
94,776 KB
testcase_18 AC 375 ms
110,312 KB
testcase_19 AC 308 ms
101,204 KB
testcase_20 AC 230 ms
91,884 KB
testcase_21 AC 430 ms
135,200 KB
testcase_22 AC 257 ms
99,264 KB
testcase_23 AC 283 ms
99,896 KB
testcase_24 AC 282 ms
100,988 KB
testcase_25 AC 279 ms
100,572 KB
testcase_26 AC 387 ms
100,636 KB
testcase_27 AC 379 ms
101,064 KB
testcase_28 AC 338 ms
108,488 KB
testcase_29 WA -
testcase_30 AC 386 ms
111,016 KB
testcase_31 WA -
testcase_32 AC 535 ms
148,692 KB
testcase_33 AC 526 ms
148,768 KB
testcase_34 AC 259 ms
98,552 KB
testcase_35 AC 270 ms
100,020 KB
testcase_36 AC 277 ms
100,692 KB
testcase_37 AC 280 ms
100,644 KB
testcase_38 AC 384 ms
100,348 KB
testcase_39 AC 385 ms
100,092 KB
testcase_40 AC 336 ms
107,640 KB
testcase_41 AC 364 ms
111,116 KB
testcase_42 AC 385 ms
112,360 KB
testcase_43 AC 388 ms
111,744 KB
testcase_44 AC 515 ms
148,948 KB
testcase_45 AC 518 ms
148,948 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=[1]
for n in R(11**5):p+=[p[-1]*P%Q]
p[-1]=pow(P,-1,Q)
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*P)%Q
S=[]
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*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-O(c[i-L]))*p[-1]+t*p[L-1])%Q
		m+=w==A[-1]
	if c=="~":
		U,V=S[int(s[1])-1],S[int(s[2])-1]
		S+=[[(U[0]+V[0]*U[1])%Q,U[1]*V[1]%Q,U[2],(U[3]+sum(U[4][i]*V[2][L-2-i]for i in R(L-1))+V[3])%P,V[4]]]
	else:S+=[[u,p[l],U,m,V]]
print(S[-1][3])
0