求助,敢问大神为什么这种会WA会T?(虽然我知道AC自动机是正解)QWQ
查看原帖
求助,敢问大神为什么这种会WA会T?(虽然我知道AC自动机是正解)QWQ
672837
DaShabby楼主2023/8/28 18:20
#include<bits/stdc++.h>
#define add_SUU ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define inf 0x3f3f3f3f
#define x first
#define y second
#define int long long
#define iter set<pii>::iterator
using namespace std;
typedef pair<int,int> pii;
const int maxn=5e5+1000;
int tot,cnt,idx;
//int vis[10000];
int MOD=1e9+7;
//vector<vector<int>>G(maxn);
map<string,int>vis;
void work(){
    int n,m,k;
    cin>>n;
    for(int i=1;i<=n;i++){
    	string s;
    	cin>>s;
    	vis[s]++;
	}
	string tmp="",s;
	cin>>s;
	for(char ch:s){
		tmp+=ch;
		if(vis.count(tmp))tot+=vis[tmp];
	}
	cout<<tot<<'\n';
}
signed main()
{
    add_SUU;
    int t=1;
//    cin>>t;
	while(t--)
    work();
    return 0;
}
2023/8/28 18:20
加载中...