結果

問題 No.2172 SEARCH in the Text Editor
ユーザー 👑 p-adicp-adic
提出日時 2023-06-23 13:28:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 625 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 122,120 KB
最終ジャッジ日時 2023-09-13 08:22:59
合計ジャッジ時間 18,602 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
86,864 KB
testcase_01 AC 85 ms
86,976 KB
testcase_02 AC 84 ms
86,804 KB
testcase_03 AC 405 ms
122,080 KB
testcase_04 AC 416 ms
121,800 KB
testcase_05 AC 417 ms
122,120 KB
testcase_06 AC 217 ms
91,988 KB
testcase_07 AC 230 ms
91,820 KB
testcase_08 AC 228 ms
92,684 KB
testcase_09 AC 303 ms
103,448 KB
testcase_10 AC 283 ms
101,212 KB
testcase_11 AC 229 ms
91,592 KB
testcase_12 AC 267 ms
98,516 KB
testcase_13 AC 277 ms
102,504 KB
testcase_14 AC 329 ms
108,212 KB
testcase_15 AC 253 ms
94,260 KB
testcase_16 AC 236 ms
90,856 KB
testcase_17 AC 244 ms
95,180 KB
testcase_18 AC 323 ms
107,176 KB
testcase_19 AC 292 ms
104,976 KB
testcase_20 AC 238 ms
91,440 KB
testcase_21 AC 317 ms
106,944 KB
testcase_22 AC 262 ms
110,808 KB
testcase_23 AC 282 ms
111,452 KB
testcase_24 AC 276 ms
111,432 KB
testcase_25 AC 289 ms
111,256 KB
testcase_26 AC 432 ms
121,920 KB
testcase_27 AC 416 ms
122,092 KB
testcase_28 AC 331 ms
111,416 KB
testcase_29 AC 349 ms
111,412 KB
testcase_30 AC 351 ms
111,524 KB
testcase_31 AC 355 ms
110,244 KB
testcase_32 AC 352 ms
112,132 KB
testcase_33 AC 350 ms
111,800 KB
testcase_34 AC 270 ms
110,452 KB
testcase_35 AC 283 ms
112,432 KB
testcase_36 AC 275 ms
111,104 KB
testcase_37 AC 280 ms
110,716 KB
testcase_38 AC 428 ms
122,024 KB
testcase_39 AC 421 ms
121,940 KB
testcase_40 AC 331 ms
111,304 KB
testcase_41 AC 345 ms
111,392 KB
testcase_42 AC 353 ms
110,628 KB
testcase_43 AC 345 ms
111,272 KB
testcase_44 AC 339 ms
112,180 KB
testcase_45 AC 341 ms
112,068 KB
testcase_46 AC 262 ms
97,448 KB
testcase_47 AC 233 ms
91,964 KB
testcase_48 AC 242 ms
93,448 KB
testcase_49 AC 308 ms
104,036 KB
testcase_50 AC 300 ms
101,912 KB
testcase_51 AC 227 ms
91,588 KB
権限があれば一括ダウンロードができます

ソースコード

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:],""][L<2]]]
	else:S+=[[sum(O(s[i])*p[i]for i in R(l))%Q,p[l],s[:L-1],C(s),[s[1-L:],""][L<2]]]
print(S[-1][3])
0