結果
| 問題 | 
                            No.2172 SEARCH in the Text Editor
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-12-24 13:34:35 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 531 bytes | 
| コンパイル時間 | 225 ms | 
| コンパイル使用メモリ | 81,896 KB | 
| 実行使用メモリ | 91,864 KB | 
| 最終ジャッジ日時 | 2024-11-18 07:17:27 | 
| 合計ジャッジ時間 | 6,308 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 WA * 23 | 
ソースコード
import sys
input = sys.stdin.readline
N = int(input())
T = input()[:-1]
L = []
MOD = 998244353
for _ in range(N):
    I = list(input().split())
    
    if len(I)==1:
        S = I[0]
        x = min(len(S), len(T)-1)
        
        if x>0:
            L.append((S.count(T), S[:x], S[-x:]))
        else:
            L.append((S.count(T), '', ''))
    else:
        i, j = int(I[1])-1, int(I[2])-1
        c = (L[i][0]+L[j][0]+(''.join([L[i][2], L[j][1]]).count(T)))%MOD
        L.append((c, L[i][1], L[j][2]))
print(L[-1][0])