【STL】hdu 5688 Problem D

xiaoxiao2021-02-28  142

Problem D

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 914    Accepted Submission(s): 556 Problem Description 度熊所居住的 D 国,是一个完全尊重人权的国度。以至于这个国家的所有人命名自己的名字都非常奇怪。一个人的名字由若干个字符组成,同样的,这些字符的全排列的结果中的每一个字符串,也都是这个人的名字。例如,如果一个人名字是 ACM,那么 AMC, CAM, MAC, MCA, 等也都是这个人的名字。在这个国家中,没有两个名字相同的人。 度熊想统计这个国家的人口数量,请帮助度熊设计一个程序,用来统计每一个人在之前被统计过多少次。   Input 这里包括一组测试数据,第一行包含一个正整数 N ,接下来的 N 行代表了 N 个名字。 N 不会超过 100,000 ,他们的名字不会超过40位.   Output 对于每输入的一个人名,输出一个整数,代表这个人之前被统计了多少次。   Sample Input 5 ACM MAC BBA ACM BAB   Sample Output 0 1 0 2 1   ///AC代码 /* *********************************************** ┆ ┏┓   ┏┓ ┆ ┆┏┛┻━━━┛┻┓ ┆ ┆┃       ┃ ┆ ┆┃   ━   ┃ ┆ ┆┃ ┳┛ ┗┳ ┃ ┆ ┆┃       ┃ ┆ ┆┃   ┻   ┃ ┆ ┆┗━┓ 马 ┏━┛ ┆ ┆  ┃ 勒 ┃  ┆       ┆  ┃ 戈 ┗━━━┓ ┆ ┆  ┃ 壁     ┣┓┆ ┆  ┃ 的草泥马  ┏┛┆ ┆  ┗┓┓┏━┳┓┏┛ ┆ ┆   ┃┫┫ ┃┫┫ ┆ ┆   ┗┻┛ ┗┻┛ ┆ ************************************************ */ #include <iostream> #include <set> #include <map> #include <stack> #include <cmath> #include <queue> #include <cstdio> #include <bitset> #include <string> #include <vector> #include <iomanip> #include <cstring> #include <algorithm> #include <functional> #define PI acos(-1) #define eps 1e-8 #define inf 0x3f3f3f3f #define debug(x) cout<<"---"<<x<<"---"<<endl typedef long long ll; using namespace std; char s[200]; map<string, int>M; int main() { int n; scanf("%d", &n); while (n--) { scanf("%s", s); int len = strlen(s); sort(s, s + len); printf("%d\n", M[s]++); } return 0; } /************************************************ ┆ ┏┓   ┏┓ ┆ ┆┏┛┻━━━┛┻┓ ┆ ┆┃       ┃ ┆ ┆┃   ━   ┃ ┆ ┆┃ ┳┛ ┗┳ ┃ ┆ ┆┃       ┃ ┆ ┆┃   ┻   ┃ ┆ ┆┗━┓   ┏━┛ ┆ ┆  ┃   ┃  ┆       ┆  ┃   ┗━━━┓ ┆ ┆  ┃  AC代马   ┣┓┆ ┆  ┃    ┏┛┆ ┆  ┗┓┓┏━┳┓┏┛ ┆ ┆   ┃┫┫ ┃┫┫ ┆ ┆   ┗┻┛ ┗┻┛ ┆ ************************************************ */
转载请注明原文地址: https://www.6miu.com/read-19212.html

最新回复(0)