分值: 19
一天蒜头君得到 n 个字符串 si,每个字符串的长度都不超过 10。
蒜头君在想,在这 n 个字符串中,以 si 为后缀的字符串有多少个呢?
输入格式
第一行输入一个整数 n。
接下来 n 行,每行输入一个字符串 si。
输出格式
输出 n 个整数,第 ii 个整数表示以 si 为后缀的字符串的个数。
数据范围
对于 50% 的数据,1≤n≤10^3。
对于 100% 的数据,1≤n≤10^5。
所有的字符串仅由小写字母组成。
样例输入复制
3
ba
a
aba
样例输出复制
2
3
1
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
string a[maxn];
int main(){
map<string,int>mp;
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
for(int j=0;j<a[i].size();j++){
mp[a[i].substr(j)]++;
}
}
for(int i=0;i<n;i++){
cout<<mp[a[i]]<<endl;
}
return 0;
}