后缀字符串|2019 蓝桥杯省赛 B 组模拟赛(一)第7题
题目链接:https://nanti.jisuanke.com/t/36115
利用map https://blog.csdn.net/caipengbenren/article/details/86632489
#include<map>
#include<string>
#include<iostream>
using namespace std;
string a[100001];
int main(){
int n;
map<string,int >cp;
scanf("%d", &n);
for(int i = 1; i <= n; i++){
cin>>a[i];
for(int j = 0; j <= a[i].size() - 1; j++){
cp[a[i].substr(j)]++;
}
}
for(int i = 1; i <= n; i++){
cout<<cp[a[i]]<<endl;
}
return 0;
}