Submission #3729011


Source Code Expand

#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
int n;
string s[1<<17];
set<unsigned long>S[700];
map<int,int>M;
vector<unsigned long>h,make;
vector<int>le;
string t;
long dp[1<<17],mod=1e9+7;
main()
{
	cin>>n;
	int sz=0;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		int l=s[i].size();
		if(M.find(l)==M.end())
		{
			M[l]=sz++;
			le.push_back(l);
			h.push_back(0);
			unsigned long now=1;
			for(int j=0;j<l;j++)
			{
				now=now*mod;
			}
			make.push_back(now);
		}
		unsigned long tmp=0;
		for(int j=0;j<l;j++)tmp=tmp*mod+s[i][j];
		S[M[l]].insert(tmp);
	}
	cin>>t;
	dp[0]=1;
	for(int i=0;i<t.size();i++)
	{
		for(int j=0;j<sz;j++)
		{
			h[j]=h[j]*mod+t[i];
			if(i>=le[j])h[j]-=t[i-le[j]]*make[j];
			if(i>=le[j]-1&&S[j].find(h[j])!=S[j].end())dp[i+1]=(dp[i+1]+dp[i+1-le[j]])%mod;
		}
	}
	cout<<dp[t.size()]<<endl;
}

Submission Info

Submission Time
Task H - Separate String
User kotatsugame
Language C++14 (GCC 5.4.1)
Score 100
Code Size 905 Byte
Status AC
Exec Time 1111 ms
Memory 4480 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 40
Set Name Test Cases
All 00_sample_00, 00_sample_01, 00_sample_02, 00_sample_03, 10_rand_00, 10_rand_01, 10_rand_02, 10_rand_03, 10_rand_04, 11_rand_00, 11_rand_01, 11_rand_02, 11_rand_03, 11_rand_04, 20_fixed_length_00, 20_fixed_length_01, 20_fixed_length_02, 21_fixed_length_00, 21_fixed_length_01, 21_fixed_length_02, 22_fixed_length_00, 22_fixed_length_01, 22_fixed_length_02, 23_fixed_length_00, 23_fixed_length_01, 23_fixed_length_02, 24_fixed_length_00, 24_fixed_length_01, 24_fixed_length_02, 30_mixed_length_00, 30_mixed_length_01, 30_mixed_length_02, 30_mixed_length_03, 30_mixed_length_04, 90_challenge_00, 90_challenge_01, 90_challenge_02, 90_challenge_03, 90_challenge_04, 90_challenge_05
Case Name Status Exec Time Memory
00_sample_00 AC 2 ms 1280 KB
00_sample_01 AC 2 ms 1280 KB
00_sample_02 AC 2 ms 1280 KB
00_sample_03 AC 2 ms 1280 KB
10_rand_00 AC 92 ms 2944 KB
10_rand_01 AC 178 ms 2432 KB
10_rand_02 AC 226 ms 3840 KB
10_rand_03 AC 248 ms 2688 KB
10_rand_04 AC 126 ms 2048 KB
11_rand_00 AC 298 ms 2816 KB
11_rand_01 AC 299 ms 3072 KB
11_rand_02 AC 297 ms 2816 KB
11_rand_03 AC 284 ms 3200 KB
11_rand_04 AC 293 ms 3328 KB
20_fixed_length_00 AC 44 ms 4480 KB
20_fixed_length_01 AC 44 ms 4480 KB
20_fixed_length_02 AC 44 ms 4480 KB
21_fixed_length_00 AC 14 ms 1792 KB
21_fixed_length_01 AC 14 ms 1792 KB
21_fixed_length_02 AC 14 ms 1792 KB
22_fixed_length_00 AC 27 ms 3072 KB
22_fixed_length_01 AC 27 ms 3072 KB
22_fixed_length_02 AC 27 ms 3072 KB
23_fixed_length_00 AC 18 ms 2560 KB
23_fixed_length_01 AC 18 ms 2560 KB
23_fixed_length_02 AC 18 ms 2560 KB
24_fixed_length_00 AC 15 ms 1920 KB
24_fixed_length_01 AC 15 ms 1920 KB
24_fixed_length_02 AC 15 ms 1920 KB
30_mixed_length_00 AC 22 ms 2688 KB
30_mixed_length_01 AC 22 ms 2688 KB
30_mixed_length_02 AC 22 ms 2688 KB
30_mixed_length_03 AC 22 ms 2688 KB
30_mixed_length_04 AC 22 ms 2688 KB
90_challenge_00 AC 44 ms 2560 KB
90_challenge_01 AC 1111 ms 2688 KB
90_challenge_02 AC 32 ms 2560 KB
90_challenge_03 AC 874 ms 2688 KB
90_challenge_04 AC 51 ms 3968 KB
90_challenge_05 AC 2 ms 1280 KB