結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,644 KB
testcase_01 AC 3 ms
9,728 KB
testcase_02 AC 3 ms
9,648 KB
testcase_03 AC 185 ms
22,836 KB
testcase_04 AC 194 ms
22,912 KB
testcase_05 AC 207 ms
22,932 KB
testcase_06 AC 12 ms
9,984 KB
testcase_07 AC 11 ms
9,924 KB
testcase_08 AC 13 ms
10,028 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 8 ms
9,856 KB
testcase_12 AC 12 ms
10,240 KB
testcase_13 AC 15 ms
10,112 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 12 ms
10,112 KB
testcase_17 AC 13 ms
10,028 KB
testcase_18 AC 17 ms
10,112 KB
testcase_19 AC 16 ms
9,984 KB
testcase_20 AC 11 ms
9,856 KB
testcase_21 AC 16 ms
9,984 KB
testcase_22 AC 27 ms
10,436 KB
testcase_23 AC 29 ms
10,484 KB
testcase_24 AC 31 ms
10,612 KB
testcase_25 AC 31 ms
10,496 KB
testcase_26 AC 200 ms
22,980 KB
testcase_27 AC 203 ms
22,912 KB
testcase_28 AC 22 ms
10,496 KB
testcase_29 WA -
testcase_30 AC 20 ms
10,564 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,564 KB
testcase_35 AC 29 ms
10,564 KB
testcase_36 AC 30 ms
10,588 KB
testcase_37 AC 31 ms
10,440 KB
testcase_38 AC 203 ms
22,984 KB
testcase_39 AC 212 ms
22,852 KB
testcase_40 AC 22 ms
10,412 KB
testcase_41 AC 22 ms
10,496 KB
testcase_42 AC 22 ms
10,564 KB
testcase_43 AC 21 ms
10,564 KB
testcase_44 AC 19 ms
10,052 KB
testcase_45 AC 19 ms
10,112 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;
			}

			b[i]=s.substr(0LL,min(n-1,m));
			a[i]=s.substr(max(0LL,m-n+1),min(n-1,m));

		}else{

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

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

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

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


		}

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


	}

	return 0;
}
0