結果
問題 | No.2172 SEARCH in the Text Editor |
ユーザー |
👑 |
提出日時 | 2023-06-23 13:28:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,144 KB |
実行使用メモリ | 120,876 KB |
最終ジャッジ日時 | 2024-06-30 18:19:57 |
合計ジャッジ時間 | 15,778 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
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])