2016"百度之星" - 资格赛(Astar Round1) 1004

 

思路:题目很简单,直接用map记录每个字符串的个数就可以了。记得对每个字符串先sort()。

 

AC代码:

#include <cstdio>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
const int MAX_N = 44;
char name[MAX_N];
int n;
map<string, int> m;
string s;
int main()
{
	//freopen("in.txt", "r", stdin);
	scanf("%d", &n);
	while(n--)
	{
		scanf("%s", name);
		sort(name, name + strlen(name));
		s = name;
		printf("%d\n", m[s]);
		m[s] ++;
	}
	return 0;
}

  

posted @ 2016-05-14 19:22  sevenun  阅读(185)  评论(0编辑  收藏  举报