/* * File: main.cpp * Author: semprathlon * * Created on May 15, 2016, 12:49 PM */ #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int uint; const int maxn=50; map mp; inline ll Hash(char *str) { ll seed = 127; ll hash = 0; while (*str) { hash = hash * seed + (*str++); } return hash; //return (hash & 0xffffffff); } char str[maxn]; int main(int argc, char** argv) { int n; scanf("%d ",&n); mp.clear(); while(n--){ gets(str); int len=strlen(str); sort(str,str+len); ll h=Hash(str); map::iterator it=mp.find(h); if (it==mp.end()){ printf("0\n"); mp.insert(make_pair(h,1)); } else{ printf("%d\n",it->second); mp[h]++; } } return 0; }