https://www.luogu.com.cn/problem/P8630
///因为密码是打乱顺序的,所以只要字母个数对上就行
///用map存字母种类和个数
///vector存每行密码
///不用set,每行独立
再考察一个字符串分割函数substr,map自动比较
#include<bits/stdc++.h>
using namespace std;
#define N 100011
typedef long long ll;
typedef pair<ll,int> pii;
string a,s;
int n;
int bo[15];
vector<map<char,int>> b;///因为密码是打乱顺序的,所以只要字母个数对上就行
///用map存字母种类和个数
///vector存每行密码
///不用set,每行独立
ll an;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>a;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s;
map<char,int> w;
for(int j=0;j<8;j++)
{
w[s[j]]++;
}
b.push_back(w);
}
for(auto c:b)
{
for(int i=0;i<=a.size()-8;i++)
///字符串分割,看看这个字符串能对上几个密码
{
map<char,int> s;
string x=a.substr(i,8);
for(int j=0;j<8;j++)
{
s[x[j]]++;
}
if(s==c) an++;///map自动比较
}
}
cout<<an;
return 0;
}