結果

問題 No.2172 SEARCH in the Text Editor
ユーザー daiotadaiota
提出日時 2022-12-24 06:06:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 958 bytes
コンパイル時間 1,658 ms
コンパイル使用メモリ 171,084 KB
実行使用メモリ 22,960 KB
最終ジャッジ日時 2024-04-29 06:10:52
合計ジャッジ時間 5,134 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,600 KB
testcase_01 AC 3 ms
9,600 KB
testcase_02 AC 3 ms
9,728 KB
testcase_03 AC 193 ms
22,852 KB
testcase_04 AC 196 ms
22,960 KB
testcase_05 AC 193 ms
22,960 KB
testcase_06 AC 12 ms
9,984 KB
testcase_07 AC 9 ms
10,096 KB
testcase_08 AC 11 ms
10,112 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 9 ms
9,800 KB
testcase_12 AC 13 ms
10,152 KB
testcase_13 AC 17 ms
10,112 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 12 ms
10,084 KB
testcase_17 AC 11 ms
10,236 KB
testcase_18 AC 16 ms
10,112 KB
testcase_19 AC 16 ms
9,984 KB
testcase_20 AC 10 ms
9,856 KB
testcase_21 AC 15 ms
9,984 KB
testcase_22 AC 27 ms
10,436 KB
testcase_23 AC 29 ms
10,496 KB
testcase_24 AC 31 ms
10,592 KB
testcase_25 AC 32 ms
10,536 KB
testcase_26 AC 196 ms
22,912 KB
testcase_27 AC 198 ms
22,912 KB
testcase_28 AC 22 ms
10,416 KB
testcase_29 WA -
testcase_30 AC 20 ms
10,368 KB
testcase_31 WA -
testcase_32 AC 19 ms
10,112 KB
testcase_33 AC 20 ms
10,112 KB
testcase_34 AC 27 ms
10,544 KB
testcase_35 AC 30 ms
10,440 KB
testcase_36 AC 31 ms
10,564 KB
testcase_37 AC 31 ms
10,496 KB
testcase_38 AC 200 ms
22,960 KB
testcase_39 AC 197 ms
22,912 KB
testcase_40 AC 19 ms
10,496 KB
testcase_41 AC 21 ms
10,436 KB
testcase_42 AC 19 ms
10,364 KB
testcase_43 AC 20 ms
10,368 KB
testcase_44 AC 20 ms
9,984 KB
testcase_45 AC 19 ms
9,984 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
typedef long long ll;
typedef pair<int,int> P;

const ll MOD=998244353;
ll c[100010];
string b[100010],a[100010];

int main(void){
	ll i,j;

	cin.tie(0);  ios_base::sync_with_stdio(false);

	ll N;
	string T;
	cin >> N >> T;

	ll n=T.size();

	for(i=1;i<=N;i++){
		string s;
		cin >> s;

		ll m=s.size();
		if(s!="~"){

			for(j=0;j<=m-n;j++) if(T==s.substr(j,n)){
				c[i]++;
				c[i]%=MOD;
			}

			if(m>=n-1){
				b[i]=s.substr(0,n-1);
				a[i]=s.substr(m-n+1,n-1);
			}else{
				b[i]=s;
				a[i]=s;
			}

		}else{

			ll J,K;
			cin >> J >> K;

			b[i]=b[J];
			a[i]=a[K];

			string x=a[J];
			x+=b[K];

			ll p=b[J].size(),q=a[K].size(),d=0;
			if(p+q>=n){
				for(j=0;j<p;j++) if(j<=p+q-n && T==x.substr(j,n)) d++;
				c[i]=c[J]+c[K]+d;
				c[i]%=MOD;
			}else{
				c[i]=c[J]+c[K];
				c[i]%=MOD;
			}


		}

		if(i==N) cout << c[N] << endl;


	}

	return 0;
}
0