Problem D
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
首先字符的全排列是同一个名字,那不妨将字符排个序,输出当前字符串出现的次数,然后将当前字符串放入map中,也算是一个简单的模拟吧
题目链接→HDU 5688 Problem D
/*Sherlock and Watson and Adler*/
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10
using namespace std;
const int N = 100005;
const int M = 45;
const int inf = 100000000;
const int mod = 9973;
char ch[M];
map<string,int> m;
int main()
{int n,i,j;string s;while(~scanf("%d",&n)){m.clear();for(i=0;i<n;i++){scanf("%s",ch);sort(ch,ch+strlen(ch));s="";for(j=0;ch[j]!='\0';j++)s+=ch[j];printf("%d\n",m[s]);m[s]++;}}return 0;
}
菜鸟成长记