#2019120500010-POJ 数据结构 映射(1)

POJ2945 数据结构 映射

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <map>
#define N 20010
using namespace std;
map<string,int> mp;
string s[N];
int n,m,tm[N];  

int main( ){
	while(~scanf("%d%d\n",&n,&m)){
		mp.clear();
		memset(tm,0,sizeof(tm));
		for(int i=1,x;i<=n;i++){
			cin>>s[i];
			x=++mp[s[i]];
			if(x>1) tm[x-1]--;
			tm[x]++;
		}
		for(int i=1;i<=n;i++) printf("%d\n",tm[i]/*," \m"[i==n]*/);
	}
	return 0;
}
posted @ 2019-12-05 22:09  刘子闻  阅读(84)  评论(0编辑  收藏  举报