后缀字符串
样例输
3 ba a aba
样例输出
2 3 1
#include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <cstdio> #include <map> using namespace std; const int maxn = 1e5 + 10; int n; string a[maxn]; map<string, int>mp; int main() { //freopen("in","r",stdin); ios::sync_with_stdio(0); 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)]++; //cout << a[i].substr(j) << " "; } } for (int i = 0; i < n; i++) cout << mp[a[i]] << endl; return 0; }