結果
問題 | No.2172 SEARCH in the Text Editor |
ユーザー |
👑 |
提出日時 | 2023-06-23 12:43:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 595 bytes |
コンパイル時間 | 256 ms |
コンパイル使用メモリ | 82,788 KB |
実行使用メモリ | 105,660 KB |
最終ジャッジ日時 | 2024-06-30 17:39:53 |
合計ジャッジ時間 | 15,026 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 WA * 12 |
ソースコード
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],(U[3]+C(U[4]+V[2])+V[3])%P,V[4]]] else:S+=[[sum(O(s[i])*p[i]for i in R(l))%Q,p[l],s[:min(l,L-1)],C(s),s[max(0,l-L+1):]]] print(S[-1][3])